It's always a great idea to check out any curious behavior with a vet visit,
but in this case because the behavior is only associated with certain emotions, I highly doubt this is an ear infection. Dogs tend to be more tipsy when they have one, compared to bending in a U shape, which seems to be more of a posture related to his emotions compared to anything health concerned.
I've had dogs that would twist their bum right to their nose and wiggle in a complete circle whenever we came home or let them out of their kennels.