The answer to this question varies with the major. The earlier you get started, the better. First, many majors, especially technical majors like engineering, have fairly rigid sequences of courses that are based on prerequisites that prevent you from moving on until you pass the required courses. If you are out of step, it may take longer to graduate than you have planned. Second, you may find that you really don’t like the major and would like to switch to something else. The sooner you can determine this, the better.
Many majors do not allow you to declare a major until you have accumulated some fixed number of credits, typically 30, 45 or 60 credits. Similarly, some majors may require you to complete some preliminary, core set of classes. When you have completed these courses and if you have achieved some established minimum grade point average, you can then declare a major.
Read the catalog. It may not be exciting, but the catalog actually represents a contract the university has with you. As the curriculum changes, as it inevitably does, the courses you are required to take, are contained in the catalog. Typically, there is an advisement office, either at a college- or university-level, that requires you to file a form to declare or to change a major. Find out where that office is and speak with the appropriate person.