I think all three sentences could be said by native speakers of American English and are grammatical, but are not equally likely and tend to mean slightly different things. Since people often speak loosely, they might be said to refer to the exact same situation.
When he was heading out to get groceries, he grabbed the key and put on the sunglasses.
This more or less means: "On his way out of the house with the intent to get groceries, he grabbed the key...." This sounds the most natural since it depicts the most typical situation. Although it does not guarantee the person left the home, it suggests it; and it would be natural to follow up this sentence with: "While then walking to the store, he saw a friend...."
When he was about to head out to get groceries, he grabbed the key and put on the sunglasses.
The expression "to be about to" implies a boundary between two events and focuses on the fact that the first event has a consequential but unpredictable relationship to the second event. Whether or not the second event is realized depends on the whole sentence read together. It is slightly unnatural to use "was about to" when the two events are normally connected in a predictable way and so don't have a strong possibility of branching outcomes. It would be fine to say: "When he was about to head out..., the phone rang and he had to answer it" or "When he was about to head out..., it started to rain, and so he decided to take his umbrella." If the focus is only on the time element, you would perhaps say: "Just before heading out..., he grabbed the key...."
When he was going to head out to get groceries, he grabbed the key and put on the sunglasses.
The sentence suggests two stages to the event of leaving and would most likely be understood to mean: "When he had finished what he was doing and was getting ready to leave to get groceries or when he had decided to get the groceries, he grabbed the key...." This sentence suggests that the timing of getting the keys and sunglasses was related to the intention to leave rather than to the actual leaving itself. It does not strongly suggest that he grabbed the key and glasses on the way heading to or out of the door, but rather got them once leaving seemed inevitable. If there were some suggestion that he grabbed the keys and put on the sunglasses before actually leaving so as not to forget them, this would be the preferred sentence.