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.