President Reagan yesterday nominated former representative Margaret M. Heckler of Massachusetts, a moderate Republican who lost her bid for reelection last fall, to replace Richard S. Schweiker as secretary of Health and Human Services.

If her nomination is approved by the Senate, Heckler will be Reagan's third female Cabinet-level appointee. She will assume command of a Cabinet department that has the third largest budget in the world--$276 billion--after the United States and the Soviet Union.

As head of the department responsible for Social Security, Medicare, Medicaid, welfare and other costly federal programs, she will move to the center stage of controversy in Reagan's efforts to reduce domestic spending.

Reagan announced Heckler's nomination in the East Room of the White House after accepting Schweiker's letter of resignation. The president praised Heckler's ability, pointing to her eight terms in the House.

"Congresswoman Heckler brings to the job extensive experience in the workings of government . . . , " he said. "She has proven herself a practical and compassionate public servant, and I am confident that she will prove an invaluable member of our team."

Heckler, 51, battled with Reagan's supporters at the 1980 Republican National Convention in her efforts to have the party platform include support of the Equal Rights Amendment. A Roman Catholic with three children, she is opposed to abortion, as is Reagan, but unlike Reagan she does not favor a constitutional amendment to outlaw it.

As the president introduced her as his nominee for HHS secretary, however, she pledged loyalty to him.

"Indeed, it is with a sense of faith in your vision and your goals for America, faith in President Reagan, that I accept what I think is the hardest assignment in Washington," she said.

Heckler becomes the second woman named to the Reagan Cabinet in a week. The president on Jan. 5 chose Elizabeth Dole, the former head of the White House's public liaison office, to succeed Drew Lewis as head of the Department of Transportation. Jeanne J. Kirkpatrick, ambassador to the United Nations, also has Cabinet-level status.

Both Heckler and Dole are regarded as political moderates succeeding political moderates.

Reagan's addition of women to his predominantly male, white Cabinet comes at a time when White House and private polls--and the 1982 election results--show him with high negative ratings among women voters for his stand against abortion and the Equal Rights Amendment and forcing social and welfare programs to bear the brunt of his budget cuts.

The president is seeking to neutralize this "gender gap" by including women in the upper reaches of his administration, according to White House aides.

But while some White House insiders view the Heckler and Dole appointments as politically motivated, they give both women high marks for intelligence and ability.

"Both Dole and Heckler are very well qualified for their jobs," one White House aide said yesterday. "They have a wealth of administrative experience. People may say it's political but in two swoops this administration has done something totally historical and precedent breaking.

"An administration that appointed a woman to the Supreme Court Sandra D. O'Connor has also appointed two women to the Cabinet. People are saying it's politics, but they're going to find something to bicker about . . . . It just goes to show you, you can't please all the people all the time."

On Capitol Hill, Republicans and Democrats alike applauded Heckler's appointment.

"Although I have disagreed with her on a number of issues, she is a responsible and talented public servant who brings real strengths to the largest domestic agency of the federal government," said Sen. Edward M. Kennedy (D-Mass.), the ranking minority member on the Senate Committee on Labor and Human Resources.

"I think they are finally beginning to realize over at the White House that it is not real wise to run the country like a men's club," said Kathy Wilson, head of the National Women's Political Caucus. "We just hope they will continue trying to repair their somewhat tattered image with women."

The resignations of Schweiker and Lewis are not the result of any political or policy disputes with the president, according to presidential aides. Both Schweiker and Lewis said they got lucrative offers in private industry that they could not be sure would still be open in two years if Reagan decides not to seek reelection.

Schweiker will become president of the American Council of Life Insurance, an umbrella group that acts as a representative for the nation's major life insurance companies. Lewis became head of a large communications company.

"During these last two years as head of the biggest and most costly department of the federal government, Dick Schweiker has proven himself in a job that has ground down lesser individuals," Reagan said in praise of Schweiker.

"I can say without hesitation that we are proud of the job that he has done . . . . I understand he has been offered a fine opportunity in the private sector, and I wish him the best of luck."

In addition to naming Heckler to head HHS yesterday, the president also named John (Jack) A. Svahn, the commissioner of Social Security since 1981, as the department's new undersecretary.

No replacement was named for Svahn, who is to succeed David B. Swoap, the former Social Security administrator who resigned to become head of California's Department of Health and Welfare.

Heckler, who would become the ninth woman ever to serve as a Cabinet secretary, was defeated in her bid for a ninth House term after her district was redrawn and she was forced to run against another incumbent, Democrat Barney Frank.

Frank dwelled on the fact that Heckler was a Republican and tried to paint her as a Reagan supporter in a district where the unemployemnt rate was 13.4 percent.

In debates with Frank, Heckler's retort to claims that she was a Reagan follower was to say that she is "not a Reagan clone . . . . I've served under five presidents, unbossed and unbought." She also complained that Reagan was not "sufficiently sensitive to women."

During Heckler's campaign, Elizabeth Dole appeared at a fund-raising lunch and told how she had been in Massachusetts when Heckler had upset former House speaker Joe Martin in 1966.

"When I was in school," Dole said, "I saw you as a woman who had the courage to take on the establishment. You were a role model for me."

Yesterday Dole dismissed suggestions that the appointment of two women to the Cabinet in a week was politically inspired. "That's ridiculous," she said.

Heckler, after losing her attempt to have the Republican Party endorse the ERA, wore a button that read: "ERA--Endorsing Reagan Anyway."

As a House member, Heckler consistently supported the president during his first year in office but in 1982 began to cast some votes opposing him, against the balanced-budget amendment and the MX missile and for the nuclear freeze.

As the best of her accomplishments in Congress she regularly cites a bill requiring the Veterans Administration to establish centers on aging in 15 hospitals and a bill giving every woman the right to obtain credit in her own name.