"Do you want something?", might possibly come across as a bit rude, depending on the situation and the speaker's tone of voice. "Did you need something?", sounds more polite, firstly, because the past tense "did" implies that when you leave, your need will already have been taken care of, and secondly, because a person has more of a right to request "something needed", as opposed to "something merely wanted". "Do you want anything?" is also fairly polite, because it implies that the speaker is willing to provide whatever s/he can.