The older ("V-1") non-threaded masts should be removed and straightened (vise or hammer). Otherwise you run the risk of splitting a sprocket. The newer threaded masts should be straightened on the Drive (without removal) or you may damage the threads. These are stronger sprockets and seem to take the straightening process in stride. Masts from the old stainless sprockets can be straightened in the Drive or removed.
I found a 3/8" galvanized pipe about 18" long to sleeve over the mast for straightening -- gives nice leverage and control; also helps keep the mast straight. Most people can just grab the mast and pull or push to straighten on the Drive (V-2 Drive) and that seems to work fine. Exact alignment is not critical, but can be determined by measuring the mast tips and bases -- should be equidistant when straight.
Masts do lose a little strength each time they bend and are straightened, but can usually take several minor or a few major bends. When they start to get easier to straighten then it's probably time to replace them. I would avoid heating a bent mast, as it can cause it to lose its temper.