Shorts are a casual piece of menswear. So when to wear them?
The simple answer is two-pronged:
1. When there’s a good reason to (temperature, environment, location) and
2. When you’re not conducting business or attending a formal ceremony/event
Recreation with family and friends is always a good default category for “shorts times.” Beaches, private parties, outdoor sports and recreation, and anything else purely for fun and not in the company of strangers or business associates is definitely in the clear.
Even those situations, of course, need appropriate weather: wearing shorts when it’s cold out is going to draw attention. Wear them when it’s hot enough that you really want them, and switch to light trousers as soon as it’s bearable. In our modern world it also seems worth saying that a man who plans on leaving an air-conditioned house to get in an air-conditioned car and drive to an air-conditioned building can endure wearing trousers no matter what the weather is like.
At the point where you have that much climate control you might as well wear the sharper-looking garment that better compliments your build. Either way just put shorts on... because women love to see legs as well.