When doing so will eliminate an amount of violence that is greater than the punch itself, once all is said and done and all individuals react to your action.
If you are elevating the level of violence with a strike, you are doing so because the sum of the violence you are permitting by not striking will exceed your strike: If a strike will eliminate harmful behavior that is less than a strike, but will continue for so long that the pain cause exceeds that of the strike, then it is justified. And of course, if you are in danger, it is justified because a world without retaliation in certain circumstances is a world that will incentivize violence.
Basically, to figure out if a strike is justified, you have to push out all thoughts of revenge, justice, temper, fairness, and heroism out of your brain. Take your action, consider the possible real life consequences of your action, and balance the good and the bad outcomes. Also, because of the severity of the action and its consequences, you must be realistic. Hitting is not the same as winning. If the person is fighting you in the first place, there is a very good chance that you hitting them will end in them breaking you. A fight may escalate things, and make the attacker feel obligated to do even more harm in retaliation. A potential fight may be diffused without violence, which is superior to violence. And in this situation, there are thousands of variables that you cannot perfectly predict. At the end of the day, whether hitting is right or wrong comes down to your capacity to make a choice based on what does the most good for the most people. Hotheadedness, a sense of honor, desire for heroics are all poor, potentially counterproductive substitutions for rational decision making.
Lastly, 3 bits of advice about fights that I learned from my dad. 1, Never start a fight, always be the one to end it. 2, fist and feet may be good, but elbows and knees are better. 3, the only fight that you should ever be in are ones where its completely fair to go for the balls. If a knee to the balls is not justified, then you shouldn't be in the fight in the first place. If it is justified, it will be effective.