A is used before words that begin with a consonant sound, like "a dog" or "a car."
An is used before words that begin with a vowel sound (a, e, i, o, u), like "an apple" or "an elephant."