How does the rule change when the batsmen attempts a switch hit. Can the umpire rule out if the ball is pitching outside leg stump and then hits the batsman in line with the stumps? By outside leg stump I meant pitching outside the leg stump if batsmen did not change his stance.
Here is a more clearer answer from LBW Wiki on this very same thing:
The batsman cannot be out lbw if the ball strikes him outside the line of off stump if he is trying to hit the ball with his bat. As some shots in cricket, such as the switch hit or reverse sweep involve the batsman switching between a right- and left-handed stance, and this impacts on where the off and leg side are located, the laws explicitly state that the off side is determined by the batsman's position when the bowler commences his run-up.
Per Law 36:
The off side of the striker’s wicket shall be determined by the striker’s stance at the moment the ball comes into play for that delivery.
The ball usually comes into play when the bowler starts his run-up.
I have also seen that umpires have sanctioned batsmen for changing their stance during the bowler's run-up (e.g., Kevin Pietersen in Sri Lanka 2012), but I don't have a source for a rule about that.