Is accepted guidance.
Know how and when to administer such punishment. Spare the rod and spoil the child. Should be a rarity and only in a private, controlled situation.
Done when the child is young (2 years old is good)
If you wait, it will not be effective then they are older. Every child is different, but the goal is to have contrition and to promote the important understanding that there are negative consequences to bad/unacceptable behavior.