Attorney General Griffin B. Bell yesterday staunchly defended the use of warrantless wiretaps, electronic surveillance and the search of sealed packages that he and President Carter authorized during the investigation of two men accused of spying for communist Vietnam.

Bell, giving the first court testimony of a U.S. attorney general, told a U.S District Court judge in Alexandria that he approved the covert intelligence gathering because "I thought in my own limited way that something had been done wrong to our country."

Bell said the different types of surveillance against former Vietnamese antiwar activist David Truong and United States Information Agency employe Ronald L. Humphrey were justified on national security grounds.

Through two hours of testimony he said repeated that the national security threat, as it was presented to him by the FBI and the State Department was being compromised.

"I was trying to protect the nation," he said. He did not elaborate on the contents of the documents that were involved, but in a previously filed affidavit he said there was concern that their disclosure might identify people in foreign countries supplying the United States with information, possibly endangering them.

Bell testified in response to defense motions to suppress much of the government's surveillance evidence on constitutional and technical grounds.

Troung and Humphrey are accused of stealing classified documents and delivering them to a network of foreign agents, several of whom are named in their indictment as unindicted coconspirators. One of them, Dinh Ba Thi, the Vietnamese ambassador to the United Nations, was asked to leave the United States soon after the original indictment was handed down.

At the close of his testimony Bell was asked by a lawyer for Humphrey whether the information and documents that were vital to the national security were passed on to the Vietnamese after being photographed by the FBI.

Bell said that they were, and began to elaborate why, when he was cut off by the defense attorney. One lawyer said later: "We didn't want him to make a speech."

Most of the classified documents involved were labeled "confidential." They were allegedly taken by Humphrey from his office at the USIA, given to Truong, and then given by Truong to a courier to be taken to Vietnamese officials in Paris.

The courier, was Dung Krall a double agent working for the CIA and the FBI. She also made her first appearance in court yesterday to testify about how and when she received the documents from Truong.

She testified that - on one occasion, on April 22, 1977, she delivered packages she received Truong to the FBI, where they were opened and inspected, repackaged and given to her to take to the Vietnamese officials in Paris.

There was no Court order or high-level administration authorization for the opening of the these packages, according to documents in the case. The FBI officials involved determined that the package - loose papers inside a George Washington University Bookstore bag tied up with string - were not "sealed," and could therefore be examined without an invasion of privacy, according to the court documents.

Defense attorneys have persistently raised the specter of unconstitutional invasions of privacy through wiretaps and searches made during the Nixon administration in the name of national security.

"This is the first time they've ever tried to litigate this issue directly," Marvin Miller, a lawyer for Truong, said after the hearing. In previous cases, he said, the wiretaps either were indirect results of other investigations, or were not used for criminal prosecutions. "Now they're saying they don't need a court order before they wiretap, and they don't need court approval afterward either."

The government's handling of the case has been marked by a series of maneuvers that suggest reservations and indecision within the Carter administration itself about the use of such measures.

Bell told a House committee that he had never authorized warrantless electronic surveillance of an American citizen, then in January sent a letter saying that he had authorized warrantless television surveillance - on Humphrey, as it turned out.

Two weeks ago the government filed a motion saying the wiretap and bugging evidence would not be used against Truong and Humphrey. The next day the government reversed that stand.

An administration-sponsored bill now before Congress would make it possible to obtain court warrants for surveillance without a rule that wiretap subjects eventually would have to be notified. Because such a rule currently exists, the government says it is difficult, if not impossible, to use court warrants in national security cases.

"What are we supposed to do until we get the new law passed? Quit?" Bell asked a group of reporters yesterday after the hearing.

A ruling on courtroom use of the evidence is expected today. Thehehe trial is scheduled for May 1.