Most bites from a ball python are a strike-and-release sort of action that happens so fast, you won't have to worry about what to "do."But on rare occasions, especially when a SFE (Stupid Feeding Error) is involved, they might bite and hang on. In that case, the safest thing to do is just to relax and wait it out. Their teeth curve back toward their throat, so if you try to pull your hand out, you'll not only rip up your own skin, you'll likely tear out teeth as well. The more relaxed you can be, the more the snake will think it has "killed" its prey and the sooner it will let go.
There are some methods that people will suggest to try and get them to let go. Most of them are bunk, in my opinion. Running water over their head is a popular one...may or may not work. Another method is to spray listerine into their mouths. I don't know for sure if that works, either...but when I took care of a burmese python for awhile, I did keep a squirt bottle of listerine nearby. I did get bit by the burm once (8' long at the time) and she held on for dear life. I didn't have the listerine at the time. Pouring water over her head did nothing except make her try to hang on tighter. I just waited it out and twenty minutes later she finally let go.