When this has happened in the past I typically respond thusly:
It has to be done immeditately:
"Oh my God! Did you see that guys shoes?'
Or,
"That waiter is pissed about something?"
Or,
"That dude over there is hilarious!"
Then followed up with:
"...Sorry, what did you say?"
The entire line of questioning is because in her mind she is comparing herself to the other woman, and somewhere along the way she realizes that she's staring at her, and judging her, and then also thinks to herself, that surely I MUST also be staring at her and judging her, and COMPARING the two of them, and I probably think she's hotter and if given the chance I'd CHOOSE the other woman over her (like the other woman wouldn't even have a say in this ridiculous day dream). All of this happens in the female mind very quickly; so you must be ready for the query at all times.
After I've redirected, that's usually enough to convince her that I wasn't checking out the other woman.
The game my wife likes to play is either.."She's pretty.'' and I say, "Who?" So that she doesn't think I was checking the chick out.
Or, "Please tell me my ass (or whatever) isn't as big (or whatever) as hers."
Which always says to me that I must immediately reply first with, "Who?" and then a sharp, "Are you crazy or something?! Hell no! You're gorgeous! Don't be ridiculous!"