Venezuelan President Luis Herrera Campins, a key ally of U.S. efforts to aid the civilian-military government in El Salvador, made clear yesterday that he opposes military action to stop Cuba and Nicaragua from helping the leftist guerrillas in the Salvadoran civil war.

"We believe there are many recourses of a political nature before going to such extreme measures," Herrera said in response to questions about using force to impede the flow of arms to the guerrillas from Cuba through Nicaragua.

The Venezuelan leader, here on a two-day official visit, made his comment in the presence of Secretary of State Alexander M. Haig Jr. following a luncheon at the State Department. Earlier, Herrera conferred with President Reagan at the White House.

During recent days, administration officials have said privately that Haig, concerned about the Salvadoran government's inability to defeat the guerrillas, has asked the Pentagon to study such options as a military blockade of Nicaragua or show-of-force maneuvers near Cuba as a means of slowing the arms flow.

The officials also have stressed that no decisions have been made about actually resorting to military measures, and there is a general impression in diplomatic circles that the administration is using uncertainty about U.S. intentions as a form of psychological pressure. In congressional testimony last week, Haig refused to give any assurances that the United States will not take action against Cuba or the revolutionary Sandinista government in Nicaragua.

Herrera's views on this issue are potentially significant because he heads the only democratically elected government in Latin America to take a position on El Salvador that parallels U.S. policy in many important respects. Where other influential Latin democracies such as Mexico have shown sympathy for the Salvadoran leftists' attempts to gain a share of governmental power, Venezuela has strongly supported President Jose Napoleon Duarte, like Herrera a Christian Democrat, and his call for settling El Salvador's political future through elections next year.

A senior U.S. official, speaking at a White House background briefing, said Herrera had reaffirmed to Reagan his support of Duarte's electoral plan, which also is endorsed by the United States. In his public comments, Herrera also seemed to dismiss suggestions that Duarte should negotiate with the guerrillas by noting that "no proposals for a constructive peace" have come from "the most violent sectors" in El Salvador.

However, Herrera also clearly was eager to dispel any idea that Venezuela might support military action or other intervention tactics in the Caribbean aimed at helping the Duarte government. In calling for adherence to political action, he said cryptically that "if violence increases and is encouraged, we believe the people of the area will turn their backs on this violence."

His choice of words left unclear whether he meant the statement as a warning that U.S. military action would provoke a hostile reaction in Latin America or whether he was condemning violence in general as a solution to the problems of the Caribbean and Central America.

Despite the convergence of Venezuelan and U.S. views on El Salvador, Herrera has advocated greater tolerance for Nicaragua than the administration lately has been disposed to show, and the Venezuelan is understood to have urged Reagan yesterday to be more supportive of the democratic elements struggling against radical pro-Cuban forces within the Nicaraguan government.