WASHINGTON (AP) _ A federal drug agent testified Thursday he was told that a White House aide leaked details of one of the government's most sensitive cocaine investigations - thus ending it prematurely - in order to expose drug smuggling by the Nicaraguan government.

Ernst Jacobsen, an undercover agent of the Drug Enforcement Administration, said that following the leak in July 1984, ''I heard from my superiors the leak came from an aide in the White House.''

While Jacobsen did not name the official, the House Judiciary subcommittee on crime released pages from Oliver L. North's diary showing the former National Security Council aide made frequent references to the operation in the weeks before the leak.

And the diary shows he was aware of photographs from the investigation showing cocaine being loaded at a Nicaraguan airstrip. A purported Nicaraguan government official who aided the smuggling operation was in the pictures.

Jacobsen, testifying from behind a screen to hide his identity, also said that shortly before the leak, a CIA agent in Miami told him the spy agency planned to leak the material to the news media to show Sandinista involvement in smuggling.

The hearing was the first in a series by the crime subcommittee into whether Reagan administration officials condoned drug smuggling and other criminal activities to further its Central American policy - especially winning aid for the Contra rebels.

The panel is particularly interested in whether administration officials obstructed law enforcement operations, as may have occurred in the 1984 nvestigation.

Panel Chairman William J. Hughes, D-N.J., said a vote on aid to the Reagan administration-backed Contra rebels in Nicaragua was moving through Congress when the story was leaked on Sandinista drug smuggling.

Jacobsen said the leak ended ''one of the most significant cocaine investigations in DEA history,'' which he said could have led to the arrest of the entire leadership of Colombia's cocaine cartel. The cartel was operating inside Nicaragua at the time, Jacobsen said.

Jacobsen testified that convicted drug pilot Barry Seal was working for the DEA in the sting operation, and had made contact with the cartel and Federico Vaughn, whom Jacobsen described as a Nicaraguan interior ministry employee.

However, the subcommittee also released information that cast doubt on Vaughn's connection with the Nicaraguan government.

Hughes said the subcommittee staff recently called Vaughn's number in Managua, Nicaragua, and spoke to a ''domestic employee'' who said the house belonged to a U.S. Embassy employee. The employee, who was not named, was among a group of U.S. officials expelled recently by Nicaragua's leftist government, Hughes said.

Hughes said his investigators were told the house has been ''continuously rented'' by the United States since 1981. He later told reporters that Vaughn's name never surfaced before the drup operation, ''and no one knew about him afterwards.''

Jacobsen said, ''To our knowledge, Federico Vaughn had no association with the U.S. Embassy or anything related to the U.S. government.''

North's diary, however, had several references to ''Freddy Vaughn'' including a July 6 entry that said, ''Freddy coming in late July.''

In the undercover operation, Seal had flown to a Nicaragua airstrip in a plane that had cameras installed by the CIA, Jacobsen said. The agent said the pictures had been developed at CIA headquarters near Washington and then ''taken to the White House.''

''The CIA wanted to release them to the press, to show the Sandinistas were dealing in cocaine,'' Jacobsen said.

The agent said DEA officials initially persuaded the CIA to change its mind, but shortly afterwards, the story on the operation appeared in The Washington Times.

He said that story caused the DEA to frantically make all the arrests possible at that point, but the operation was over.

A second DEA official who testified after Jacobsen said he met with North about the operation before the news story was leaked, and the former NSC aide ''asked when the operation could go public.''

Ron Caffrey, who was in charge of the DEA cocaine desk at the time, said North ''did indicate to me there was a vote coming up on an appropriation bill to aid the Contras. I told him public disclosure would come from the U.S. attorney or the attorney general ... but we had a lot of goals left in the investigation.''

Caffrey added that North came up with a plan to use the investigation to aide the Contras.

The agent said he told North that the chief DEA operative in the sting planned to fly $1.5 million into Nicaragua to pay for drugs already brought back from that country.

''Colonel North asked why we couldn't land the plane outside Managua and turn the money over to the Contras,'' Caffrey said, adding he told North that plan would jeopardize the operation.

Frank Monastero, former assistant administrator of the DEA, told the subcommittee that the day the news story appeared, an irate North called him to deny that he was responsible for the leak.

Monastero said that North accused the DEA of telling a reporter that North was the source of the information.

''He called to say he did not leak the information and the proof was the facts (in the story) were not accurate,'' Monastero said. ''My response was, 'That's the standard way to cover your tracks.' I didn't accept that.''

Monastero said at another point, ''I thought the leak came from the White House because of the Contra vote that was coming up.''