The Indefinite Articles an is used before a word that starts with a vowel sound. If it starts with a consonant sound, use a. Bear in mind that the key word here is SOUND: it does not matter whether the word starts with a vowel or a consonant, it is a question of whether it starts with a vowel or a consonant sound.
Some examples:
I'll be there in an hour.
(As the 'h' in hour is silent, the word sounds like it is spelt 'our')
I always wanted to have a unicorn.
(unicorn is pronounced with a "y" sound at the beginning as though it were spelt "younicorn")
An SAS soldier.
(Although it is a consonant, the name of the letter 'S' is pronounced ess /ˈɛs/)
A one hour class.
(One is pronounced with a "w" sound at the beginning like it were spelt "wone")