If the first sound of the following word is a vowel sound (whether or not the letter is a vowel), use an.
an elephant, an hour, an honour, an urn
If the first sound of the following word is a consonant sound (whether or not the letter is a consonant), use a.
a helicopter, a hotel, a union
Using this rule, use an with acronyms such as MRI and STD. (MRI stands for magnetic resonance imaging and STD for sexually transmitted disease.)
an HIV patient (human immunodeficiency virus)
A and an are known as determiners. They are also called indefinite articles. The, which is also a determiner, is commonly called the definite article.
ESL Grammar online course
The ESL Grammar online course focuses on determiners, prepositions and tenses (A$39).