Upon signing your "2 for 7," aka contract committing yourself to the Navy/Marine Corps for the next seven years when you start your junior year, the Navy begins screening you medically. These are called "precomissioning physicals" or precoms. The poke and prod you to qualify or disqualify you from the different communities. At this point, if you don't have perfect eyesight and meet the medical standards to get PRK, they offer it to you and schedule you for the surgery later that year.
As for aviation in particular, to be considered, you must pass the aviation part of the precoms, have the required vision (uncorrected or with PRK), and pass the ASTB (Aviation Selection Test Battery). It is basically a aptitude test that the Navy/Marine Corps use to help its selection for aviators. More information can be found here:
http://www.nomi.med.navy.mil/NAMI/astb/astbwebsitewriteup.htm
With all this, the aviation selection panel sits down in the fall of your senior year and starts looking at candidates. At this point, everything factors in, including class rank, performance grades, academic grades, physical fitness, your ASTB score, extracurriculars, etc. There is no set method for them picking a person for aviation. They look at the "whole person." I know people in my class in the 800s (out of 1000 or so) that still picked up Navy Pilot.