Solution 1:

The question of "a" vs "an" is always decided by the pronunciation of the word that follows the article. Thus, various geographical regions that have different pronunciation rules may use a different article for the same word.

Words that begin with a vowel sound, such as "apple", "egg", or "hour" are preceded by "an".

All other words, such as "cake", "pie", and "user" (which begins with a y sound), are preceded by "a".

Except (as lifted from @Nohat's comment below) - The rules before "h" are a little tricky, but clear: if a word begins with an "h" sound and the first syllable is stressed (like "house"), then it never takes "an". If the first syllable is not stressed (like "historical") then it is possible to use "an". Some usage authorities would say you must use "an" in those cases, but Nohat is not one of those authorities. You find both "a" and "an" used before words like "historical".


So to answer your actual question:

He ate a green apple.
He ate an enormous Pop-Tart.

"Green" does not begin with a vowel sound, so we use "a".
"Enormous", on the other hand, does begin with a vowel sound, so we use "an".

Solution 2:

There is a bizarre urban legend of sorts that you're "supposed to" use "an" if the head noun in the noun phrase it determines begins with a vowel sound, rather than the first word in the noun phrase, giving rise to claims that "an green apple" is somehow "technically" correct. Here is a blog post of someone who seems to have gotten this idea. And here is the discussion on Language Log about that blog post.

In any case, the rule is that you use "an" if the next word begins with a vowel sound. Vowel sound is crucial here because many words that begin with vowel letters do not begin with vowel sounds (e.g. user) and vice versa (e.g. hour).

This makes it a kind of sandhi rule for "intrusive N" in English for indefinite articles, avoiding hiatus between the article and the following word.