WASHINGTON (AP) _ The White House, looking for a temporary replacement for Health and Human Services Secretary Margaret M. Heckler, is considering promoting the department's budget officer to make him eligible for the post.

Sources in the department and on Capitol Hill, who spoke on condition of anonymity, said President Reagan is expected to name John O'Shaughnessy, now the department's assistant secretary for management and budget, to become undersecretary, the department's No. 2 post.

While the appointment would be a promotion, it is intended mainly to make O'Shaughnessy eligible to serve as acting secretary after Mrs. Heckler's departure to become ambassador to Ireland, the sources said.

O'Shaughnessy is not related to Mrs. Heckler, whose name was O'Shaughnessy before her marriage.

By law, an acting Cabinet secretary must be a presidential appointee who already has undergone Senate confirmation.

While five of the department's assistant secretary slots require Senate approval, O'Shaughnessy's is not one of them. Thus, he must go through the Senate confirmation proceedings before becoming legally eligible for the post.

The procedure is necessary because the long battle between Mrs. Heckler and the White House staff, which ended in her decision last week to step down as secretary to become ambassador, included an impasse over selection of high- level appointments.

As a result, vacancies exist in nine of the 16 positions in HHS ordinarily filled with presidential appointees confirmed by the Senate.

Of the remaining seven, only two are HHS assistant secretaries. They are Stephanie Lee-Miller, assistant secretary for public affairs, and Dorcas Hardy, assistant secretary for human development, who controls a $6 billion budget for programs such as Head Start.

Mrs. Heckler, upon her departure, could designate either Ms. Lee-Miller or Ms. Hardy as her acting replacement, but could choose no one else.

President Reagan, however, can name any of his appointees in the government to become acting secretary for 30 days, providing they have undergone Senate confirmation for their current posts.

Within HHS, that expands the possible list to include the inspector general; the surgeon general; the director of the National Institutes of Health; the director of the Alcohol, Drug Abuse and Mental Health Administration and the commissioner of children, youth and families.

Each of those candidates has problems, however, primarily because their posts are so specialized that none has experience in the overall workings of the 145,000-employee, $330 billion department. An exception is the inspector general, who is familiar with the workings but is supposed to police them, not run them.

The sources said the solution is expected to be elevating O'Shaughnessy, 41, a Harvard-trained public administrator who was Republican staff director for the House Budget Committee before becoming the HHS budget officer.

Sen. Dan Quayle, R-Ind., who has been promoting former Indiana Gov. Otis R. Bowen, a physician, for the post, says he met with Reagan about a permanent successor to Mrs. Heckler and Reagan ''said he is in the process of compiling a list of qualified candidates for the HHS position, and he said that 'Doc' Bowen is now on that list.''

Sources in the department and on Capitol Hill say the list of possible successors is expanding, but that only a few are being discussed widely.

David Swoap, California's outgoing health and welfare secretary who recently announced his plans to join a governmental relations consulting firm, appears at the top of most lists.

Swoap served as HHS undersecretary before taking the California post, and he is fresh from a legislative victory there in the form of a new ''workfare'' program for state welfare recipients.

Others who have been mentioned include John Svahn, the president's domestic policy adviser and a former HHS undersecretary; Pennsylvania Gov. Richard Thornburgh, who has said he wants to remain as governor and is considering a possible run for the Senate next year; Dr. Tirso del Junco, a well-known figure in California's Hispanic community and a former head of the state GOP; Karl Bays, chairman and chief executive officer of the American Hospital Supply Corp.; and Anne L. Armstrong, former co-chairman of the Republican National Committee and a former ambassador.