Typically, you won’t get in trouble for hitting someone if they have assumed the risk of being punched. This happens in sports and consensual fights.