Investigators bugged Pentagon offices for nearly two years as part of a massive investigation of alleged fraud, bribery and bid-fixing in military purchasing, but President Reagan did not learn about the operation until Tuesday, the White House said Wednesday.

Spokesman Marlin Fitzwater said Reagan received a briefing from Secretary of Defense Frank C. Carlucci on Tuesday afternoon, after the FBI disclosed the investigation. Earlier in the day, coordinated raids were staged at the Pentagon and defense contractors in 12 states."We were not aware of it until yesterday," the presidential spokesman said.

Fitzwater said White House Chief of Staff Howard H. Baker Jr. called Attorney General Edwin Meese III Wednesday, at Reagan's direction, "to discuss the president's conviction that the investigation by the Justice Department and FBI must be pursued thoroughly and conclusively."

Fitzwater said the agencies "were doing an outstanding job" of the investigation already but "the president wants to give the American people assurances that whatever is wrong in that process is going to be cleaned up."

FBI agents searched the files of two top Pentagon officials, a former Navy official and some of the nation's largest defense contractors Tuesday. Officials said the investigation focuses on sales of sophisticated electronic gear to the military.

The investigation involves "allegations of fraud and bribery on the part of defense contractors, consultants and U.S. government employees," FBI spokesman Gregory Jones said.

A Navy source who spoke on condition of anonymity said the investigation began with a tip from a former Navy department employee to the Naval Investigative Service. The Justice Department said the probe has been under way for two years.

Federal law enforcement sources, speaking on condition of anonymity, said the FBI had installed court-authorized wire taps at several locations in the Pentagon as part of the investigation.

The wire taps, according to sources, were in place for much of the two-year investigation.

Search warrants were served by the FBI and the Naval Investigative Service at the Pentagon and more than 30 locations in 12 states, the Justice Department said.

A Northrop Corp. plant that was searched in Newbury Park, Calif., produces target drone airplanes and is working on development of a new tactical missile, the AGM-136A, for the Air Force and Navy.

Three offices of Norden Systems Inc. in Connecticut, which produces radar equipment for the Navy and Air Force, were among the locations searched, according to the U.S. attorney in New Haven, Stanley Twardy.

Federal investigators sealed off and searched the Pentagon office of Victor Cohen, the civilian official responsible for buying tactical battle command, control, communications and computer systems for the Air Force.

Also sealed off and searched was the Pentagon office of James Gaines, deputy assistant secretary of the Navy for acquisition management, international programs and congressional support.

Law enforcement sources said the investigation involves the alleged sale of information by Pentagon officials to defense contractors through middlemen who were acting as consultants to the contractors. In many cases they were previous Department of Defense employees who had ready access to various Pentagon officials.