First of all, I understand why you posted on this board, but it's not really a subject for this board. You would have been better posting it on the "Infideltiy", "Cheated On", or "Relationship Myths" boards. I tell you this because sometimes posts will be deleted if they stray off topic. The topic of this one is reserved for those that are currently, or have been, the other women in affairs with married men.
That said, you need to stop seeing this as "right" or "wrong" behavior. You are getting mired in the question of "why", so you are missing the point.
The point is, he IS doing it, and he is doing it in your presense. You are hurt, and he is intentionally hurting you. Stop wondering WHY, and face the fact that he wants to hurt you. You can wonder about it all day, but if he is not going to be honest with you and explain his behavior- like, I'm feeling neglected, or taken for granted, or I'm feeling like I missed out on something in life, or whatever- then you will forever be in the dark. Instead of lamenting the fact that you are in the dark, do something about the way he's making you feel.
Confront him and say something like, "Look, I have no idea why you are acting like a 17 year old boy all of a sudden, but you are. I have been embarrassed and ashamed to be around you when you are acting this way. It's come to my attention that others see you acting this way also, and they give me pitying looks. I don't want their pity, I want you to grow up and be the man I married. If you can't do that, and respect me as the wife you've been married to all these years, we're in big trouble!"
I wouldn't give him any ultimatums, like "I'll divorce you if you don't do what I want." Ultimatums have a way of backfiring, and making us either put up or shut up, so you don't want to do that. You want to be truthful, but point out that his behavior is hurtful and you don't like it, and that others see it also (which they do!)
If he asks you what you mean by "big trouble" explain to him that you don't know the extent of it yet, as you don't know what is prompting his behavior. The goal is to get him talking to you honestly about what is going on with him.
I wish you luck, come back and let us know how it goes, but maybe choose a different board?