Yeh'll do sommat useful or yeh'll get out. In years past, punishments for rule-breaking at Hogwarts were severe indeed. Nowadays, the punishments do not typically involve physical torture, but nevertheless they can be extremely unpleasant. Teachers are given the freedom to choose the type of punishment they mete out, and Snape makes good use of this power to make life miserable for miscreants. Punishments vary according to the nature of the crime.
Some infractions result in points being deducted from the offender's house.
For other more serious offenses, detentions are handed out. Teachers may assign detention tasks as they wish and some detentions have been actually dangerous. If a student refuses to accept the detention, they will be expelled.