In Hogwarts School of Witchcraft and Wizardry, the many underage wizards and witches are kept under control by the teachers through the many rules set there.
Any miscreants are usually punished by the teachers or the Ministry of Magic, and the form of punishment depends on the severity of the mischief. Some detentions may overlap with student events, such as Quidditch and Hogsmeade weekend trips, in which the punishment would take priority, forcing the student to forgo said events.
Such examples can include doing something dangerous (such as entering the Forbidden Forest to help Rubeus Hagrid) or doing physical labour and other tasks without magic. A popular form of detention is making wrongdoers polish the school's many ornate candelabra.