President Reagan announced yesterday that Margaret M. Heckler, his secretary of health and human services, had agreed to leave the Cabinet and become ambassador to Ireland, a post he said is not a "dumping ground."

Reagan, with Heckler at his side, appeared in the White House briefing room yesterday to denounce what he called the "malicious gossip" that he was getting rid of her because she was incompetent or insufficiently conservative.

In a raucous atmosphere of shouted questions, frequent interruptions and obvious skepticism among the reporters he was addressing, the president took center stage to say that he was responsible for a job shift that White House officials said had been engineered by his chief of staff, Donald T. Regan. Heckler, at first fighting back tears, defiantly defended her record in managing the $330 billion-a-year agency and said that "the Great Communicator" had talked her into becoming ambassador.

Administration and congressional sources said that former HHS undersecretary David B. Swoap, Pennsylvania Gov. Richard L. Thornburgh (R) and James Cavanaugh, a health specialist in the Nixon administration, were among prospective candidates to become HHS secretary. Some officials said that John A. Svahn, the White House domestic policy chief who was formerly Heckler's deputy, was also a possibility even though Reagan yesterday said that he would not be appointed.

A White House official said the selection process would take about two weeks and would start with a list of a half-dozen names that would be whittled down by Regan before a recommendation is made to the president.

Praising Heckler, Reagan said: "She has done a fine job at HHS. And, therefore, if she hadn't been doing as well as she had been doing, I certainly would not have picked Ireland, or any embassy for that matter, but Ireland especially -- for her to take that post."

But some members of Congress were highly critical of the appearance of using an ambassadorial post as a place to send an unwanted Cabinet member. Rep. Edward J. Markey (D-Mass.) praised Heckler, whom he said would make "a fine ambassador," but said "the appointment hadn't been made to compliment either her or Ireland. In insulting an Irish-American woman, you wind up insulting the Irish question."

Heckler's maiden name is O'Shaughnessy. She served 16 years in the House from Massachusetts, where she made a reputation as a moderate to liberal Republican. In her comments yesterday, Heckler said it would be "a very exciting challenge" to be ambassador at a time the Republic of Ireland is involved in negotiations with Britain aimed at some form of reconciliation with Northern Ireland.

Some Republicans criticized the handling of Heckler's dismissal from the Cabinet. Sen. Rudy Boschwitz (R-Minn.), a member of a group of Senate Republicans who discussed tax issues with the president yesterday, criticized the White House leaks that he said had humiliated Heckler.

Despite many reports that his chief of staff had been the leader of the attempt to oust Heckler, Reagan in his unusual appearance declined to identify those he said had been responsible for "absolutely unjustified" leaks and "falsehoods" that he was displeased with her performance. Under questioning, the president said she could have remained as HHS secretary if she had chosen to, though White House officials said Monday that her effective choice was to take the ambassadorship or leave the administration.

Reagan did not use the word "promotion" to describe the job change as his spokesman Larry Speakes had done Monday, but he said he valued her job and that she would have a title that is "retained for life."

Heckler, answering a question on whether she felt she was being demoted to a job that pays $16,000 less than her current one, answered inaccurately that her ambassadorial salary would be tax-free.

One former Reagan administration official said that Swoap appears to have the inside track as Heckler's replacement because of his experience and his attractiveness to conservatives. He served in the Reagan administration in California, at one point as director of welfare, and has held a variety of congressional posts.

One conservative did not take seriously Reagan's ruling out of Svahn, observing that "after all, it was only recently that the president said Heckler would remain in her job."

Thornburgh said through a spokesman that he has received "some feelers from Washington on the job" but that "he has made it clear that he intends to remain as governor to the end of his term." Staff writers David Hoffman and Paul Taylor contributed to this report. CAPTION: Picture, Heckler, appearing with the president, defended her stewardship of HHS, a $330 billion-a-year agency. By Frank Johnston-The Washington Post