It depends on the context. If you are talking about any kind of official disciplinary system with rules and punishments, then any of these may work: infraction, violation, transgression, breach, contravention and various others. In this case, for example:
Dying your hair pink is a serious transgression of school policy.
You can also say the action itself is banned, restricted, prohibited, forbidden, barred, or simply not allowed.
Dying your hair pink is against school policy.
If instead you are talking about something that goes against social or moral norms, you could use (with varying degrees of severity): taboo, anathema, frowned on, proscribed, off limits, no-no, unmentionable, abomination, faux pas and others:
Smoking in restaurants, which once was common practice, is now practically a tabooa hanging offense in many parts of the United States.
(edit) These terms cover a wide range of severity. As mentioned in the comments, "transgression" is pretty serious, while "against the rules" is fairly mild. Please provide more details about how "bad" you want it to sound, and I can be more specific.