"A" is used before a word that starts with a consonant sound. "An" is used before a word that starts with a vowel sound. Below are some examples:
a cat
an apple
a big elephant
an elephant
a sweet sentiment
an irritating sound
Note that it is the sound and not the letter that matters:
a unicorn (The first sound in "unicorn" is /j/, a consonant sound.)
an honor (The first sound in "honor" is /ɑ/, a vowel sound.)
"An" is used before "FYI" because it is pronounced /ˌɛfˌwaɪˈaɪ/ and so the first sound is /ɛ/, a vowel sound.
I hope this helps.