Ability is determined by the PID, so it's set at the same time as nature/gender/shininess when the egg is first generated. You'll have to start over if you want a different ability, and you can abuse the PID if you really want to be sure.
Check out Smogon's new Doubles
Black 2 FC:
My Pokécheck Pokémon
RNG is kind of like firing a gun. Why shoot blindly in every direction until you're lucky enough to hit the target when you can just take the time to aim properly and hit it with one shot?