There is no set rule on when you should apply to medical school. Some people apply as early as 20 and others apply as late as 50. You should apply to medical school when you feel that your application is competitive and that you feel you are ready for the challenges of being a medical student.
Note that statistically, the longer out of college an applicant is, the higher their chances are of gaining admissions into a medical school. However, this is not because medical schools favor old applicants. It is because older applicants generally have more life experiences that make them a better fit for medical school. The average age of students entering medical school is 24 or 25.