We use a or an before a singular noun, when we mention something for the first time (It's a dog), or when we talk about jobs (She's an actress).
We use a before the words starting with consonant sounds (a book, a uniform) and an before vowel sounds (an umbrella, an hour).
For more visual explanation, watch this video:
Try the exercises here.