It is not a question of when to wear sunglasses, but rather when not to. Sunglasses are a fashion accessory and should only be worn on certain occasions.
A pair of sunglasses can make an outfit look more stylish and appealing. But, if you wear it during an inappropriate occasion, it can make you look like a try-hard, unapproachable and unsociable, or that they're trying to hide something. There are certain occasions where sunglasses are appropriate and others where they would be frowned upon.
In general, men should avoid wearing sunglasses in places that require eye contact.