Using an and a does not depend on the spelling of the word it comes before, it depends on the pronunciation of the word. In most cases though, an is used before words that begin with vowels (a, e, i, o u.):
an apple
an elephant
an igloo
an oven
an umbrella
If a word starts with a consonant sound, use a.
a ball
a car
a doll
It is very important to know that when a word starts with a vowel sound, you should use an. Sometimes u is pronounced as y. Try saying these two words, see if notice how the u is pronounced in two different ways.
an unforgettable experience - unforgettable has a vowel sound so we use an.
a university - university has a y sound so we use a.
This is also the case with o, which may sometimes have a w sound. Compare:
an octopus - octopus starts with a vowel sound.
a one track mind - one-track starts has a w sound.
Sometimes with words that begin with h, the h sound is not pronounced. Unfortunately there is no rule about when the h is silent. Let's look at an example.
an honour - the h is silent. We use an because the honour has a vowel sound because the h is not pronounced: (h)onour.
a historic day - the h is pronounced. Historic starts with an h sound.
Now decide if an or a is needed in these sentences. Remember to focus on how the key words are pronounced: