It depends on the grammatical gender of a noun. These have to be memorized.
Saying "et gutt" instead of "en gutt" is like saying "an boy" in English. The genders have to be memorized.
Pronounciation question: is the only audible difference between "er" and "har" the vowel sound between [æ] and [a]?
The 'h' is pronounced as well in 'har' :)
But you should learn to distinguish 'æ' and 'a', as they're distinct in Norwegian, and many words differ only by these. her/har, bær/bar, tær/tar, vær/var.
Im afraid im never going to remember to spell 'barnet' with a 't' at the end. :-( Same with 'det'. I always want to add an 'r'!