IMHO you won't teach her not to peck by pecking her. It's the same as saying to a kid we don't hit and then spanking them. I don't think your hen will connect your hitting her with her attacking your child. Personally I'd get rid of her in some fashion. Sell her, give her away or make her supper. My hens have never attacked me. They like to pick stuff off my pants and I have one that bites me if I pat her on her left side. So I pat her on her right side.
I'm sorry my solutions might not be what you want, but chickens are not dogs or horses etc. They are not that easily trained they way you are suggesting. Now my chickens know their names, they know "back" when I want to get in the coop, they know "out" when I am working in the coop, and they will "come" when I have treats. As far as discipline I don't think they connect their bad behaviors with it. Good luck. Protect your children