In general, students are expected to declare a major in the US by the end of the 3rd/4th semester or the second year of the course. This allows students to explore different electives and choose the one they are the most interested in after declaring their major. They get ample time for hands-on research before committing to their intended major.