Never. Often, there is quite a big difference between the message you think you are sending and the message that is being received.
Primarily, parents believe that a swat/spank will send a firm message that x, y or z is totally unacceptable, dangerous or whatever. What is actually being received by the child is "when someone does something that I don't want them to do, and I want them not to do it again, I should hit them." which is not a good message to be sending - it's often totally unintentional but parents don't always appreciate that they model the behaviour that their children go on to display themselves.
It's not even necessary. There are other ways to teach or send the right message to children, plenty of parents manage not to swat/spank and don't have unruly children. It takes more time and effort, but it's definitely possible and absolutely worth it.
Bottom line, children are equals - if you wouldn't hit your OH to teach him not to do something again, then why is it any different for a child? Them taking longer to learn/understand doesn't mean pain needs to be introduced to the equation. Though, in my experience, it doesn't take them all that long to understand - not with attentive, understanding parenting.