Being consequent and punishing being naughty accordingly is one of the most essential parts of raising a child. You don't need to spank or slap for minor offenses. You don't slap if your kid's broken something. Then you point out what they've done wrong and punish them in some other way. I think it's appropriate to slap after your child made an inappropriate remark. If they are being rude, it deserves a light slap. You don't need to express anger or hate while doing it. If the pain lasts for 5 seconds, it's OK.
It's essential that your child understands what it's done wrong. It doesn't help anybody if you slap the child without it knowing what it's done wrong, or if it comes to you to confess something. If they've done something bad, explain what they've done, why it's bad and why they shouldn't do it anymore. Then punish them in a non-physical way. Slapping is a way of associating an act or behaviour or statement such as racial slurs or derogatory terms with an unpleasant feeling. It's teaching them not to use it. You're doing it wrong if your child fears you. You're doing it wrong if it behaves differently among friends when you're looking. However, children can use some discipline, and if they're behaving inappropriately, slapping is a method to stop them from doing it. It's not gonna hurt them mentally. A slap is not going to cause a life-long scars. I don't remember any slaps my mum's given me, but I know she did it when we said bad things or when we spoke back. It's taught me discipline and respect, something I see rarely among today's youth.