IMO, if the child has not listened to a warning (actually, with me generally more than one!) and it is something potentially dangerous. This can include things like deliberately pulling away to attempt to run onto a road, deliberately going off the property, deliberately attempting to play with dangerous items etc
As to whether it works - most times it works. Mainly because it's a last resort type thing that only happens in serious situations, IMO. Sometimes - when something is "too fun" (like leaving the property and running up the road, then giggling and running faster if someone follows!) other methods have had to be employed. I suspect that it's mainly because by the time you catch the little so-and-so, they've already had a heap of fun, and the fun is well and truly over by the time they get punishment. As long as it's immediate and not the first port of call for punishment, (and, naturally, never done in anger!) then it works.
As I'm sure pretty much everyone here who smacks will be aware, a "good smack" will never leave a mark - smacks aren't for "dishing out pain", but for shock value. That's why sometimes a hard, loud smack NEXT to the child can work just as well to get their attention. I will utilise a sudden sharp sound (like smacking the table etc) as an alternative to get attention. It doesn't work anywhere near as well, but it can give a smaller shock value if they don't realise it's coming.