Venezuela plans to cut off Nicaragua's oil supply unless President Anastasio Somoza resigns within two weeks, according to U.S. officials and leaders of the opposition here.

The ultimatum has the tacit support of the Carter administration although there has been no formal American response and none is likely, these same sources said.

As a victim of the Arab oil boycott in 1973, the United States has vigorously opposed the principle of oil embargoes. Venezuela, which refused to join the 1973 boycott, is the sole supplier of Nicaragua's oil.

Several opposition leaders who met with Venezuela President Carlos Andres Perez last weekend in Caracas said he had personally "pledged to cut off Nicaragua's oil imminently," as one of them put it.

Perez, who along with the Carter-administration openly opposes Somoza, has given financial and political support to the Sandanista guerrillas whose attacks led to a violent two-weeks civil war last September.

The United States has organized a mediation effort here that is barely disguised offensive to force an end to the 42 years of rule by the Somoza family. Internal opposition to Somoza not only is causing incessant violence in Nicaragua but is posting a serious threat to the stability of all of Central America.

Over the last 33 days, enjoys of the United States the Dominican Republic and Guatemala have achieved a fragile coalition among opposition groups to head a transition government. But the negotiators are now nervously looking at the clock.

The opposition coalition and the Sandanista guerrillas have announced that Nov. 20 is their deadline for Somoza to leave the country. On Monday, the mediators were handed a formal reply of Somoza's Liberal Party in the back, that sort of thing" - and which does not contemplate his resignation. A broad-based new guerrilla attack is expected here before Nov. 20 if the talks fail.

"We have not quite stalled, but we're reaching the end of the string," a Key U.S. source here says.

Venezuela currently supplies Nicaragua 450,000 barrels of oil per month, half in crude and half semi-refined. The American Esso Corp. mixes and refines the oil in the country's only refinery. According to sources familiar with the energy picture, the country has reserves to last for about three weeks. "But Esso is a worldwide corporation and can easily draw on supplies elsewhere, unless the U.S. government persuades it not to," these sources said.

In anticipation of such a boycott, Somoza has already held talks with other governments to act as a front to buy oil for him, according to government sources here, who say Somoza is hoping to get such support from the government of Haiti or Taiwan.

Parallel to the Venezuelan threat, U.S. relations with Nicaragua are moving now from cool to openly hostile and U.S. diplomats are contemplating further measures to step up the pressure on Somoza this week.

Last week, after strong U.S. lobbying, the International Monetary Fund in Washington postponed a $20 million "compensation loan," vital to the nearly bankrupt Nicaraguan economy. The president of the Central Bank on Monday announced angrily that Nicaragua was now withdrawing the loan request.

Other contemplated measures, according to qualified U.S. sources, are the holdup of nearly $44 million already committed in U.S. loans, withdrawal of the U.S. ambassador here, as well as an embargo of U.S. goods to Nicaragua, whose largely agricultural economy depends strongly on outside markets.

Despite the backing by Venezuela of the Sandanista guerrillas, it is still known to favor the U.S. solution to end Nicaragua's civil strife - that is, Somoza's leaving office. A new guerrilla offensive would inevitably lead to much new bloodshed and destruction.

In the last two months at least 3,000 people have been killed in street fighting and during the government's air strafing attacks of five cities, according to Red Cross estimates.

Every day, new bodies are found most victims of the National Guard and some in retaliation by the guerrillas. Yesterday, Sen. Ramiro Granera, secretary of the Senate and one of the Somoza's close advisers, was killed. His death was explained here in opposition circles as a retaliation for what one alleged was the "execution of 14 guerillas by the National Guard" last week. Publicly, Somoza appears to be hardening his position. Before a massive rally of government employes, designed to demonstrates popular support, Somoza said Sunday he was ready for more pressures from the Carter's Administration and would not resign.

As foreign publications published photgraphs of armed Nicaraguan guerrillas in training, Somoza began showing off the strength and the firing power of his 8,100 strong National Guard with a military parade and television programs showing soldiers at target practice.

Hundreds of families continued to flee the country and the tension is becoming tangible as Nicaraguans preparing for an expected showdown between the guerrillas and the National Guard.