I was never spanked as a child. I wish I had been. I do spank my daughter.
I spank her for lying, being disobedient or disrespectful. I never yell at her, call her names or belittle her when I spank her.
When I decided to start spanking, she was 5 (I will start earlier with my next child). I explianed to her at which behaviors would earn a spanking. "If you ever lie to me, I will spank you" or "If I call you to come to me and you ignore me and don't come, I will spank you".
They key after that point is consistency. If I said "If you do that again, I'll spank you", I did it 100% of the time. There were NEVER empty threats.
If she lied, then I would calmly explain to her that "I am going to spank you for lying. You will have a very hard time in life if you grow up to be a liar and because I love you so very much, I am going to spank you so you realize how serious it is to lie. I want you to know that I love you very much and nothing is more important to me that you grow up to be happy"
I would give her a hug and a kiss and I would bend her over my knee and spank her with a wooden spoon 3 times (bare bottom). She always cries and is a little mad at first. If she gets an attitude I tell her to stay in her room by herself until she is ready to quit pouting. Sometimes she stops right away. If she does, I hug her and tell her I love her and talk a little more about what she did wrong. "God doesn't like it when people lie/are disobedient to their parents/whatever".
I am very consistent, so I don't have to spank very often. Never spank while you are angry, you could hurt them or all they end up remembering is your anger, not the lesson or what they did wrong.
You spank your kids because you love them and want them to turn out decent; make sure they understand that. If they are young, they may not understand that with words, but they can understand that by your actions.