Many foreign governments have been cooperating with U.S. efforts to prevent cocaine from entering this country, but some foreign officials have undermined American efforts by accepting bribes from drug smugglers, the President's Commission on Organized Crime was told yesterday.

Assistant Secretary of State Jon R. Thomas testified about the cooperation of South American governments in eradicating cocaine production. But three American pilots who were arrested for smuggling cocaine into the United States testified that they had been able to operate by paying off officials in the Bahamas, where they stopped en route from South America.

Stopping in the Bahamas was necessary, the pilots said, because U.S. officials were suspicious that planes flying directly to the United States from South America had drugs on board.

"I had no problem with Bahamian authorities," testified one of the men, Luis Garcia, who said he was granted immunity from prosecution by a federal court in Miami. "I paid from the lowly constable to the assistant superintendent of police."

Several Drug Enforcement Administration officials, two U.S. Customs Service officials and a U.S. Coast Guard commander also testified during the commission's second day of hearings on cocaine trafficking.

Garcia, who lives in Miami, said some Colombian and Cuban officials he met seemed less than honest. On one of his trips to Colombia to pick up cocaine, he testified, the cocaine producers invited him to a party also attended by some Colombian prosecutors, judges, national police and politicians.

"I was introduced as an American smuggler," Garcia testified.

Garcia also testified that Cuban officials approached him in 1979 and suggested that he use their island as a stopover on his drug-smuggling trips in exchange for bringing electronic equipment into Cuba. Garcia did not say whether he accepted the alleged offer.

Thomas testified that Latin American and South American officials are giving high priority to controlling narcotics production and trafficking. He mentioned the Colombian government's efforts at spraying marijuana plants with herbicides and removing coca plants by hand, and its plans to spray coca plants with herbicides.

"The Colombians have paid a tragic price for their intensive campaign," Thomas said.

"On April 30, Minister of Justice Rodrigo Lara Bonilla , outspoken advocate of strong antinarcotics controls, was machine-gunned to death on a residential street in Bogota in a contract murder appar- ently financed by narcotics traffickers."

Thomas testified that Peruvians also have paid for their antidrug efforts. Last week, he said, drug smugglers in Peru killed 19 Peruvians working in a U.S.-financed program aimed at eradicating coca crops.

"We are told that four of these workers were cruelly tortured and may have been skinned alive," Thomas testified, adding that neither the United States nor "our Latin American colleagues" will be deterred in their efforts to stop cocaine production.

Despite these efforts at con- trolling drug-making, Thomas said there has been no evidence of a reduction in the amount of heroin or cocaine coming into the United States.

While commission members were listening to testimony, a judge in Kingman, Ariz., set bond at $1 million each for four men accused of smuggling billions of dollars' worth of cocaine into the United States.

The four men had flown to an abandoned World War II airstrip Monday; a vacationing detective spotted the fresh airplane tracks there.