Severely reprimand, make someone pure by correcting or reproving them. Castigation, chastisement, or chiding is the infliction of severe punishment. In earlier times, castigation specifically meant restoring one to a religiously pure state, called chastity.
Example, China's support for its currency - the yuan - has been castigated inside the American beltway as an unfair trade subsidy.
In Christian times, this terminology was adopted but roughly restricted to the physical sphere: chastity became a matter of approved sexual conduct, castigation usually meaning physical punishment, either as a form of penance, as a voluntary pious exercise (see mortification of the flesh) or as educational or other coercion, while the use for other (e.g. verbal) punishments (and criticism etc.) is now often perceived as metaphorical. 
Self-castigation is applied by the repentant culprit to himself, for moral and/or religious reasons, notably as penance.
From c.1600, "to correct; to purify; chastise, punish.