"to chastise, punish," c. 1600, from Latin castigatus, past participle of castigare "to correct, set right; purify; chastise, punish," from castus "pure" (see caste) + agere "to do" (from PIE root *ag- "to drive, draw out or forth, move"). The notion behind the word is "make someone pure by correction or reproof." Compare purge (v.), from purus + agere. Related: Castigated; castigating; castigator; castigatory.
If thou didst put this soure cold habit on To castigate thy pride, 'twere well. [Shakespeare, "Timon" IV.iii (1607)]