Health and Human Services Secretary Otis R. Bowen told a congressional panel yesterday that the Reagan administration opposes legislation to protect persons infected with the AIDS virus because "each state should be able to set its own rules."

Bowen said that even though the absence of federal laws to safeguard the privacy of AIDS-infected people and bar discrimination against them might jeopardize the administration's testing policy, Congress should not "rush in" before the states can act.

"I would not necessarily oppose all new federal legislation on this issue, but . . . it is preferable to defer action on specific proposals for new substantive rights or new enforcement procedures," Bowen told the House Energy and Commerce subcommittee on health and the environment, which is considering several bills to control the spread of acquired immune deficiency syndrome.

For these reasons, Bowen said, the administration opposes a bill sponsored by Rep. Henry A. Waxman (D-Calif.), chairman of the subcommittee, as well as several mandatory testing measures sponsored by Rep. William E. Dannemeyer (D-Calif.)

White House spokesman Marlin Fitzwater, traveling with President Reagan in New York, said, "We oppose discrimination . . . but we do believe the states probably have a preemptive responsibility in this area."

Waxman's bill, regarded as the chief AIDS testing measure before Congress, has the support of major health-care organizations including the American Medical Association. The bill would authorize spending $1.2 billion over the next three years to expand voluntary counseling and testing; prohibit disclosing test results except in specific situations, and permit civil penalties against those who breach confidentiality. The bill also would bar discrimination against those who test positive.

Dannemeyer's measures would require testing of certain hospital patients and clients of sexually transmitted disease clinics. It would also require health officials to collect the names and addresses of those infected and contact their sexual partners.

The administration's opposition to Waxman's bill -- a companion measure in the Senate is sponsored by Sen. Edward M. Kennedy (D-Mass.) -- had been expected.

In June Reagan, saying AIDS is "surreptitiously spreading throughout our population," called for wider routine testing for prisoners, immigrants, couples seeking marriage licenses and those seeking treatment for sexually transmitted diseases or drug abuse.

Several weeks later the AMA, a powerful, generally conservative group that represents most of the nation's doctors, rejected Reagan's call in favor of widespread voluntary testing, counseling and new laws protecting civil liberties of those who are tested.

The administration's position places Bowen in an awkward position. Officials within HHS, including Surgeon General C. Everett Koop and Dr. James O. Mason, director of the Centers for Disease Control, have warned that the lack of strong civil rights protections will probably doom widespread testing and drive the epidemic underground.

Waxman focused on this apparent contradiction, noting that 21 states lack laws protecting confidentiality of the results of tests for sexually transmitted diseases, including AIDS. "If the administration wants more widespread testing, aren't we jeopardizing {its} success if we don't assure {confidentiality} at the federal level for all Americans?" he asked Bowen.

Bowen said that although some people might not agree to be tested without new safeguards, the primary issue is "whether we should rush into it on the federal level or leave it up to the states."

Rep. Ron Wyden (D-Ore.) predicted that Bowen's approach would lead to a "crazy quilt" of state laws. "It makes no sense to try and transfer the leadership to states . . . . We wouldn't do that in the event of a war."

Dr. Reed V. Tuckson, commissioner of Public Health for the District of Columbia, which ranks fifth among the states in the number of reported AIDS cases, praised the bill. "People who already live on the margins need to be reassured" that test results will not lead to discrimination, he said.