As to the actual origins of the phrase "where do you get off...?", I'd point out that, first, the idiom is essentially identical in meaning and usage to "Who do you think you are, to do such-and-such?!?!" -- in other words, "Do you think you're [the Pope? The President? An Egyptian pharaoh? A Five-Star General? An important billionaire industrialist?, etc.*], and that gives you the right to be a total asshole?"

So, I hope that clears up any doubts Hanna has about when to use the expression.

Given the phrase's "don't be so high-and-mighty"* meaning, perhaps it did actually originate as an imagined conversation between two train passengers -- as in, "Do you actually live in such a high-class neighborhood that you can speak like that to ordinary people?" And perhaps there was the additional suggestion that actual Popes/Presidents/billionaires would not be riding the train at all, but would have a chauffeured limo.

But that's only speculation -- I'm really not sure what the origins are. So my advice to Hanna is not to worry too much about the logical meaning of the phrase, but you can use it in any circumstances where you'd say sarcastically "And who are you, the Queen of #$%^& England?!"

* P.S. But it's not always about "high-and-mighty"-ness. In the case of "calling Jill fat", the implied comparison is "Do you think you're the Venus de Milo?", or some other standard of physical beauty. In the case of "Where do you get off lying to me?", the comparison might be something like, "Do you think you're my parents, telling me that my hamster Harry ran away to join the Hamster Foreign Legion when I was 8 years old?"