The U.S. State Department has cleared the way for a controversial military aid package for Somalia, first proposed by the Carter administration and urged as part of a generally expanded American role in the Horn of Africa by advisers to President-elect Reagan, U.S. officials here said.

By determining that no Somali troops are fighting in Ethiopia's contested Ogaden region, the department has cleared the congressional restriction on a $40 million package of military supplies to be exchanged for U.S. military use of Somali facilities.

[In Washington, a State Department official confirmed the decision, saying, "Our program provides only defensive arms in Somalia and so should not contribute to a resumption of fighting in the Ogaden."]

The military supplies seem likely to trigger complaints by Somalia's hostile neighbors, Kenya and Ethiopia, and involve the United States in the intractable dispute in the Horn of Africa. The State Department assessment on which the supplies depend, and of which Congress already has been informed, was reached in the last days of the Carter administration and has yet to be made public.

The State Department determination was disclosed this week by Rep. Clarence Long (D-Md.) during a tour of Africa. Long, chairman of a House subcommittee dealing with foreign aid, said the department notified him before he left on the trip last week.

The American Embassy here, which apparently first learned of the move from Long during a brief visit, confirmed the action.

The sensitivity of the move was emphasized today when the Somali Foreign Ministry charged that Ethiopia has stationed 100,000 troops, supported by Soviet and Cuban advisers, along the border and plans to invade northern Somalia to capture the strategic port of Berbera on the Gulf of Aden.

American military use of the Berbera airport and harbor is the key reason for the controversial agreement to provide Somalia with arms. The installations, originally built by the Soviets before they switched their support to Ethiopia in 1977, are to be used by the newly developed Rapid Deployment Force to beef up U.S. military presence in the Indian Ocean following the Soviet invasion of Afghanistan.

Although Somalia and Ethiopia have frequently made exaggerated claims during their decades-old feud over the Ogaden, any Ethiopian move across the border, even in the guise of supporting dissident Somali elements, could present President-elect Ronald Reagan with an immediate crisis in Africa.

Former secretary of state Henry Kissinger, visiting Somalia earlier this month, spoke of an Ethiopian "threat" to Somalia form Soviet "expansionism" and said the new administration "believes that expansionism must be checked."

Technically, Kissinger's visit was billed as private, but it would be hard to persuade officials in the volatile Horn of Africa that he was not speaking for Reagan.

The U.S. government signed the arms-for-facilities agreement with Somalia last August, but no military hardware has been provided because Congress stipulated that the State Department first had to give "verified assurance" that there were no Somali troops in the mainly barren Ogaden area, which is about the size of New Mexico.

As late as last month, American diplomats clearly still felt there were Somali troops in the area despite the country's claims that the fighting was being carried out by the Western Somali Liberation Front, a guerrilla organization supported by Somalia.

At the conclusion of a meeting last month, Kenyan President Daniel arap Moj and Marxist Ethiopian leader Lt. Col. Mengistu Haile Mariam sharply attacked what they said were Somalia's territorial ambitions. Both nations, which have large ethnic Somali populations, have been involved in wars with Somalia over its demand for self-determination for all Somali-speaking people.

Ethiopia, a close U.S. ally until the overthrow of Emperor Haile Selassie in 1974, has received $1.5 billion in Soviet arms in the past three years and is supported by 13,000 Cuban troops. Capitalist Kenya is a major recipient of U.S. aid, but its concerns about territory in this case outweigh ideological affinities.