HOUSTON (AP) _ Mayoral candidate Louie Welch, unaware that his microphone was on, said on live television that one way to stop AIDS would be to ''shoot the queers.''

He was preparing to discuss a plan for fighting the spread of the deadly disease, most victims of which have been homosexuals, on KTRK-TV's ''Live at Five'' show Thursday afternoon when he made the comment.

KTRK-TV aired a live shot of Welch, said he would appear later on the program, then switched to another scene. Thinking his microphone was off, Welch joked about his four-point plan, saying ''one of 'em (is) to shoot the queers.''

The comment was broadcast when a technician accidentally turned up Welch's microphone instead of that of a reporter in the next scene, KTRK news director Jim Topping said.

Welch later told KTRK that he was ''just horsin' around'' when he made the ''unfortunate remark.''

''I apologize,'' he said.

Welch also said he was in good company because President Reagan had made a similar slip-up once. Reagan once joked about bombing Russia during a microphone test that was not broadcast.

But gay political leaders were not amused.

''It's a sick joke - if it's a joke,'' said Sue Lovell, president of Houston's Gay Political Caucus.

''Even given the fact he said this in jest - despite that fact, Welch is commonly perceived as anti-gay,'' said attorney Tom Coleman, who is vice president of the GPC and head of the Texas Human Rights Foundation.

Mayor Kathy Whitmire said her campaign headquarters was flooded with calls after the television program aired.

''We have had a number of calls about it and a lot of people asking us about it,'' she said, declining to comment further because she had not seen the program.

Welch, 66, is a former five-term mayor who recently introduced the prevention of acquired immune deficiency syndrome as a campaign issue in the mayor's race.

Mrs. Whitmire, 39, is seeking re-election to her third term and has received the support of the homosexual community in her campaign bids.