In one of the hardest fought contests ever held for a subcommittee post, Rep. Henry A. Waxman, a third-term Democrat from California, yesterday defeated veteran Rep. Richardson Preyer (D-N.C.) for the chairmanship of the key health subcommittee on the House Commerce Committee.

The 15-to-12 vote against Preyer was a defeat for the seniority system and members of the leadership who had backed Preyer, and a victory for labor, consumer and environmental groups and junior members who had backed Waxman.

In another Commerce subcommittee fight, Rep. Bob Eckhardt, a Texas Democrat who has championed comsumer causes and fought the oil companies, defeated the more senior Rep. John M. Murphy (D-N.Y.), a defender of many special interests, for the chairmanship of the oversight subcommittee.

The vote against Murphy was 18 to 9.

The Commerce health subcommittee will be a crucial spot in the current Congress because it will handle legislation to control hospital costs, a Carter administration priority; national health insurance, and attempts to postpone or weaken clean air standards.

Waxman said after his victory yesterday that health insurance legislation would probably not pass in this session of Congress, and President Carter's cost containment proposal "will have a very difficult time."

Waxman, a liberal, was careful not to align himself on national health insurance with either the comprehensive program advocated by Sen. Edward M. Kennedy (D-Mass.) and labor, or the less costly version sought by the administration. "We'll have to see what we can afford and how we can make it equitable," Waxman said:

The Waxman-Preyer fight became bitter in the last few weeks and was won only in the last day or so when Rep. Timothy E. Wirth (D-Colo.) and Rep. Mickey Leland (D-Tex.) came over to Waxman's side.

Preyer, a respected senior member with a reputation for integrity, was stung by charges of conflict of interest, arising out of his family's ownership of drug company stock, and was attacked by the American Cancer Society and others for his criticism of recent statistics dealing with the health hazards of smoking.

Leland, a pharmacist who took the seat of retired Rep. Barbara Jordan (D-Tex.), said he considered himself "a No. 1 enemy of the pharmaceutical industry" and Preyer's drug holdings bothered him. He acknowledged that he had been asked by Majority Leader Jim Wright (D-Tex.) to support Preyer.

Waxman, who comes from a district that takes in wealthy Beverly Hills, Calif., was stung by criticism of his giving campaign funds to some of his colleagues on the Commerce Committee.

Rep. Richard Bolling (D-Mo.) had criticized Waxman for this during a recent meeting of the Democratic Steering and Policy Committee.

Bolling had also implied Waxman was abusing reforms that allow chairmanship challenges by going after a man of Preyer's reputation.

Waxman, obviously still angry, said Bolling and others had "done more damage to the institution" than he knew and said he thought it was a "healthy thing" to have challenges to chairmen no matter who they were.

"The thing I think is most significant is the impace on the seniority system," Waxman said. He also sharply criticized "some members of the leadership," whom he accused of trying to fill five vacancies on the Commerce Committee with members sympathetic to Preyer. He named only Bolling.

Murphy's candidacy for the oversight slot was looked upon primarily as a "power grab" by some members. Murphy already chairs the Merchant Marine Committee, a Merchant Marine subcommittee and the Select Committee on the Outer Continental Shelf. Before the voting, Murphy did promise to give up the subcommittee on Merchant Marine.

Eckhardt, who succeeds retired Rep. John Moss (D-Calif.) as chairman of the oversight subcommittee, indicated he would be less interested in attacking agencies than Moss was and would concentrate on "investigations" into the "unnecessary costs" of housing, energy and food.

By a surprisingly close vote of 14 to 13, Rep. James H. Scheuer (D-N.Y.) was elected to chair the Consumer subcommittee Eckhardt gave up. Rep. James J. Florio (D-N.J.) will replace defeated Rep. Fred Rooney (D-Pa.) as chairman of the transportation subcommittee.