Unless you get to be CEO, at some point in your career you'll work for somebody younger. When that happens it stings for a lot of reasons. It is an unpleasant right of passage like the loss of an older friend or grandparent. It tells you where you are in your career unless you do something drastic to shake things up. What it tells you about your career status may hold true even if you do shake things up.
Organizations, as much as they may try to adopt egalitarian language, are pyramids. There are fewer positions the higher up you go. Along the way you reach a point past which you won't rise higher. You know that in your intellectual mind just like your know your own mortality. You just don't want it brought front of mind like when one supervisor moves on or retires and the next one is younger than you.
This can happen for several reasons. You can be a professional in a skill that supports, but is not at the core of, your employer. I'm an HR professional in a publishing company, for example.
Other less pleasant reasons for a younger boss are that the company thinks this youngster is better suited for tomorrow's skills, or that they've assessed the two of you and just think the other person has more potential.
So after you get the news and absorb the shock, what's there to do? Here are some suggestions.
1. Don't chalk it up to discrimination. If you take the easy way out you'll miss the self-examination that is needed for you to benefit from this development.
2. Ask the decision makers why it wasn't you. Also ask what you would need to do to be the right candidate next time, if they're willing to support you in that effort, and what they see your career track to be going forward.
3. Seek advise outside your company. Get a second opinion and decide for yourself if your company is right or if they're just made a terrible oversight as to your potential.
4. Make a decision and move forward positively. Whether you decide to shop your skills on the market, seek to close the skill gap with your current employer, or transfer to another department, do it. Do it and don't let the decision cause your performance to erode through poor attitude. You can't make a positive change in a negative frame of mind; people smell it. You can, with the same amount of energy and a better outcome, turn other's negative opinions of you into motivation.
To handle this type of career turning point you must first expect it. Unless you're going to work for yourself, or be CEO, it is going to happen. Skip the anger, self-doubt, and suspicion and turn it into the energy needed to deal with this inevitable point in your career.