How to react when professor wrongly corrects you in public?
Did you pass your thesis defense? If so, it's all water under the bridge.
If it is eating you up inside, you could send a polite note to the senior professor (cc:ing your advisor) thanking them for the question and that now that you've had a chance to re-check things, that you are ever more certain that your method is different from the suggested prior method because of x, y, and z; but perhaps you misunderstood his question and there was another earlier method he was referring to, and if so -- could he please send the reference? (tip of the hat to @gnometorule)
If you go this route, I would frame it as a letter of thanks, appreciation, scholarly inquiry, and to keep the tone as non-accusatory as possible. As @guifa notes, some jerks professors view thesis defenses as a type of hazing -- a no-holds-barred opportunity to test your mettle; and what happens in defense should stay in defense. You do not want to drag this out. It can easily blow back in your face or the face of your advisor if the senior faculty member has a thin skin (which unfortunately many academics seem to have).
Again, if you have your Masters, then I would just be happy with that and just make rude gestures towards that senior faculty member from the safety and privacy of your own home. And don't ever do this when you become that person in a position of power.
You changed the question slightly from the initial posting from [what to do after the fact] to [what you should have done at the moment]. As note above, all questions at thesis defenses are fair -- even ones that are built on false or falsified premises. It is, after all, a "defense" and as a scientist you should be able to defend yourself from both truthful and false/falsified statements without having to resort to ad hominem counter-attacks. You respond based on your training and experience what you believe to be correct. And obviously given that you passed the defense, the examiners thought that you gave satisfactory responses on the whole. As Queen Elsa teaches us, let it go.
Forget about it and go on with your day.
Generally, when faced with questions or comments like this one, you need to respond in a way that is open to the possibility that the professor is right, but that nonetheless demonstrates your belief in your own position. Don't give ground too easily, but don't get too entrenched either, since you need to be open to new information.
How you do this depends on how specific the professor's comment is:
If it was just a vague contradiction - "That's not new, it's been around for ages" - then you need to probe for more information. "That's interesting, I've not come across any previous use of this method - could you tell me more about where it's been used?".
If prof responds in detail ("It was done by Professor X in paper Y") and paper Y is not one you've come across, then your response is similar. "That's really interesting, I will look into that. Perhaps we can discuss this further after the talk." Or you might be able to second-guess the method used even if you don't know paper Y. "If they used method Z, then it's related, but our is different because..."
If paper Y is one that you are familiar with, then you have something concrete you can discuss. "That's certainly an important method, and provided inspiration for our work [if it did], but I referred to our method as new because it has these important advances/differences..."
However rude the professor is with their comment, it may still be a valid point, so try not to take it personally. Ignore the tone and just respond to the substance as politely and scientifically as you can.
Finally, it's easy to say all this in hindsight, but when it's early in your career and you're faced with an imposing figure contradicting you, it is only natural to give ground under pressure, and the fact that you successfully defended your thesis shows that you coped well with the overall situation!