In the United States, it is slightly formal. I would not use it with family or close friends. A friend would greet me with "Hi, Dan." Someone trying to be respectful to me might say "Good morning, Mr. Smith.
It's customary when someone is talking to a group of people: "Good afternoon, class." I would use it with business colleagues if I were running a meeting. "Good afternoon, folks. A copy of the agenda is on the table in front of you, and..."
Of course, we would say "Good morning," "Good afternoon," or "Good evening" depending on the time of day. Around 1 p.m. or so it is fairly common for someone to say, awkwardly, "Good morning--uh, uh, I mean, good afternoon."