David A. Stockman, the chief architect of President Reagan's effort to shrink the federal government and a center of controversy during 4 1/2 years as director of the Office of Management and Budget, resigned yesterday to join the New York investment banking firm of Salomon Brothers.

White House spokesman Larry Speakes issued a terse announcement of the resignation, due to take effect Aug. 1, and read a brief statement from the president lauding Stockman.

Speakes said there was no timetable for replacing the budget director and only "a mental list" of possible candidates to replace him.

Administration officials speculated that this list includes but is not necessarily limited to Drew Lewis, the former transportation secretary who is now chief executive officer for Warner-Amex; Secretary of Commerce Malcolm Baldrige; Deputy Secretary of the Treasury Richard G. Darman and Alton Keel, associate director of the Office of Management and Budget for national security and international affairs.

Keel is believed to be Stockman's recommendation for his replacement. Darman, who a Treasury spokesman said was "not interested" in the job, is considered highly qualified but likely to encounter conservative opposition on Capitol Hill. Baldrige has made it known he wants the job but is not believed to have the favor of White House chief of staff Donald T. Regan and other high officials.

Lewis, who was unavailable for comment yesterday, would likely be a popular choice on Capitol Hill. One GOP senator, who said he did not know whether Lewis is available, predicted that the former Cabinet officer would have the easiest time winning Senate confirmation.

In Reagan's statement, he praised Stockman for his "dedication and distinction."

"His tireless effort to bring fiscal discipline to the federal government and ensure economic stability for the country are deeply appreciated," Reagan said.

Although Stockman, 38, leaves with praise from the president, he has in the past received sharp criticism from Reagan, high administration officials and members of Congress of both parties for his outspoken opinions on fiscal issues and his candid warnings about the consequences of the burgeoning federal deficit.

Earlier this year Stockman touched off a controversy when he assailed military pensions and said that many of the nation's farmers had brought their troubles on themselves. The comments caused Reagan to say, "I can understand a fellow blowing his cool."

Stockman's departure had been widely expected for several months even though the timing, at a crucial moment in budget negotiations, surprised some Republican senators. The budget director's salary is $75,100 a year; some reports say he will make as much as a $1 million annually at Salomon Brothers, where his salary was not disclosed.

In New York, John H. Gutfreund, chairman and chief executive officer of Salomon Brothers, said Stockman would join the firm Nov. 1 as a managing director involved in corporate and governmental finance.

On Capitol Hill, where he served as a Republican House member from Michigan, Stockman was praised yesterday even by lawmakers who had sometimes been critical of him in the past.

"He's going to leave a gaping hole," said Sen. Paul Laxalt (R-Nev.), an intimate of the president. "He's developed tremendous respect and will be sorely missed."

Sen. Pete V. Domenici (R-N.M.) chairman of the Senate Budget Committee, said, "He has had more impact and been the most effective OMB director we've ever had."

Sen. Alan K. Simpson (R-Wyo.), who said Stockman will be "a first-class act wherever he goes," said the budget director did not mention his plans at a morning meeting with congressional leaders at the White House but said he wore "a great, big broad smile" that should have tipped them off.

But congressional reaction to Stockman was not unanimous. Sen. Ernest F. Hollings (D-S.C.), a Democratic presidential candidate in 1984, said Stockman was "too clever . . . for the country" and said "the truth has sort of caught up with him." Pointing to rosy OMB economic projections earlier this year that have now been widely rejected, Hollings said, "He was too smart, too clever. He was misleading at almost every turn on all those blooming figures."

Stockman's departure completes a turnover in the Reagan administration that began in the middle of the first term and has gained momentum since the president's reelection. Of the leading Reagan administration officials sworn in at the beginning of the first term, nearly every one has left or changed jobs except for Defense Secretary Caspar W. Weinberger and Baldrige.