Use a when the first letter of the word following has the sound of a consonant. Keep in mind that some vowels can sound like consonants, such as when they're sounded out as individual letters. Also, some letters, notably h and u, sometimes act as consonants (home, usual), other times as vowels (honest, unusual).
a U-turn (pronounced "yoo")
a NASA study
Use an when the first letter of the word following has the sound of a vowel.
an unfair charge
an honor (the h is silent)
an HMO plan (H is pronounced "aitch")
an NAACP convention (the N is pronounced "en")