In boxing, when you deliberately headbutt, it's a way of telling your opponent that they are in for a street fight. A brawl. Ortiz is an idiot for engaging with his opponent before the ref called 'box'. It's his own fault he got KOed. The ref says 'protect yourself at all times' at the start of the fight for good reason.
Mayweather did the wrong thing and the fight should have been deemed a no contest, not a victory, but Ortiz copped an old fashioned boxing lesson. If you want to fight dirty, expect your opponent will do the same. And be prepared for the consequences.