For OBR, the applicable rules are 6.06b, batter switching batter's boxes, and 8.01f, ambidextous pitcher.
Once an ambidextous pitcher declares with what hand he is pitching with, he must stay with that hand until the batter is out, the batter reaches base, the inning ends, the batter is substituted for or due to an injury. If he switches due to injury, he may not pitch with that hand again for the duration of the game.
The batter may switch boxes at any time other than when the pitcher is in position ready to pitch.