When do you use a vs an?

Generally, "a" is used in front of a consonant, and "an" is used in front of a vowel, or vowel-sound - a 'y' or a soft 'h'.