How To Get My Kitten To Stop Biting?

My kitten is biting me on the leg. He’s never done it before and he doesn’t bite hard at all…but sometimes its hurts so bad I have to get up out of my bed. What can I do to stop him from doing this?