Only a child's parents should be allowed to spank them.
Agreed on that.
Spanking might be appropriate, said Eric Berne, for actions that can get someone hurt -- like tampering with electrical cords, playing with fire, shouting racial epithets at minorities, or throwing stones at dogs. The idea is that one does not want to get electrical or physical burns, get into fights, or face retaliation from a large and dangerous predator.
The idea is to associate the misconduct with pain. Failing to get an adequate grade? Saying a dirty word? No.
In my state, teachers and administrators are not allowed to inflict corporal punishment upon any child. I have seen much student misconduct, but I have never been tempted to punish a child for it physically.
I felt corporal punishment once in school, and after that I held the teacher in contempt for the rest of the school year. She had it in for me for misspelling a word early in the year on the board -- and that I exposed it. It took her until late May of that year for her to catch me talking out of turn. Second grade. Bureaucratic toadying is not my idea of something appropriate to teach second-graders.