teach a lesson
Punish in order to prevent a recurrence of bad behavior. For example, Timmy set the wastebasket on fire; that should teach him a lesson about playing with matches. This term uses lesson in the sense of "a punishment or rebuke," a usage dating from the late 1500s. Also see learn one's lesson.
Dictionary.com presents 366 FAQs, incorporating some of the frequently asked questions from the past with newer queries.