I get leg cramps as well, but can't say that I've had them in connection with orgasms. Flexing the foot works for me, as does standing up (which is basically the same as flexing the foot, but is sometimes easier). I usually get them in the middle of the night and am woken up from a dead sleep.
Now, as far as your leg cramps go...are they only with clitoral orgasms and masturbation or do you get them with a partner? It could be a simple matter of positioning. If your leg ends up in an awkward position to accommodate your hand or arm, that could be enough to trigger the cramp. Try using the other hand or changing your position completely. Hopefully the cramps will go away (and you can have fun trying!

)