I'm torn on this. On the one hand, I get that asking about how someone makes their money is sort of personal. On the other hand, I believe that consumers have a right to a transparent transaction. I'm a scientist. Every single paper I publish includes a section that acknowledges funding and any conflicts of interest, And I think that is how it should be. I feel like I have a right to know if a salesperson might have an additional motive to sell me item A over item B. It just seems like part of doing due diligence. So in general, I think that asking about a potential conflict of interest (and commission can be a huge conflict of interest) surrounding a recommendation is acceptable.
In fact, one thing I love about my financial planner is that he is always upfront about how he makes his money and which options make him more or less money. Sometimes he recommends the one that nets him more, sometimes he recommends the one that nets him less. But his openness about it helps with the trust. If I ever need a new financial planner, I would refuse to use one that didn't provide this level of disclosure.
So basically, I like transparency.
In the case of the OP, the cashier was snotty. Even if it was a rude question (and I think it is one that can be rude or not depending on the circumstances), there are right and wrong ways to handle a rude question. For this specific scenario (since OP is unconcerned with knowing about any potential bias and only wants to see the salesperson get credit), the wording "Jim was really helpful today, I'd like to make sure he gets credit for the sale, if that is appropriate." could work. That way the cashier doesn't feel put on the spot to come up with an answer.