Shifting body weight for a turn
Before you read this, make sure you understand how to turn a bike.
When shifting weight for a corner, the butt, hips, and upper body should move together and remain parallel to the bike. Use the big muscles of the outside leg pressing against the tank to support your body weight. These principles apply whether you are shifting just a bit for an easy curve, are hanging off a fair ways in the twisties, or dragging a knee at the track. Don't just lean your upper body and leave your butt on the seat, and don't leave your upper body over the gas cap with your butt off to the side. Your head should be upright with your eyes level with the horizon. Note that the head/elbow/knee are off board about the same amount.
When you start to exit the curve, it's time to shift your weight back to the center of the bike. Use the power in the outside leg against the tank, not your arms and shoulders, to haul yourself back on board.
What not to do
These photos are from a track day. Going to a track school is the best way to learn and practice this technique. However, this is an extension of the weight-shifting techniques discussed above. Shifting weight for a turn is something that should be done as a matter of routine, but go slowly and work up to this level.
The following photographs show common mistakes and how to remedy them.
In this picture, the rider's outside leg is very separated from the bike. That makes it hard to control your body position, and to bring yourself back on board from hanging off. It can also mean you are supporting your weight almost entirely with your arms and shoulders, which can compromise your ability to keep a relaxed, sensitive arm/hand connection to the steering. Keep the outside knee against the bike. Using the big muscles in the outside hip and thigh should make your whole body more relaxed. This lets the bike work better and reduces the amount of negative inputs from you.
With your body next to the bike on the inside of the corner, your outside knee/calf is what stops you from falling off the inside. You shouldn't be supporting your body weight with your arms. They are steering. Your leg muscles are what should move your body from side to side, not your arms.
Here, the outside leg is far back when hanging off. The butt is hanging off, but the upper body is still mostly over the bike. Try arranging yourself so that your outside thigh is against or close to the gas tank. Then, lean forward to lower your upper body somewhat toward the inside grip, while still keeping your head upright and turned. This rider has that part right. That way, your whole inside hip-to-chest-to-shoulder axis is hanging off, more or less parallel to the bike.