Forty-two U.S. military and economic assistance programs in about 30 countries will have to be eliminated and dozens of others reduced drastically this year because of congressional budget cuts and other restrictions on the foreign aid program, the State Department said yesterday.

U.S. officials are particularly concerned about the impact of the cuts in three countries where the U.S. has military bases considered vital by the Pentagon: Turkey, Portugal and the Philippines.

Turkey was allocated $334 million and the Philippines $125 million in military aid, both increases over last year. But the Reagan administration, which had pledged to seek $125 million for Turkey in economic aid, said it can provide only $32 million, and it cut funds for the Philippines from $250 million last year to $174 million in 1988.

Portugal, which received $147 million last year, will receive only $117 million, a cut that could prompt the Lisbon government to demand a review of the accord giving the United States a strategic air base in the Azores Islands, administration officials said. Portuguese officials have complained that when the most recent base agreement was signed in 1983, the United States promised an annual aid level of $205 million.

Reflecting administration frustration with Congress' actions, State Department spokesman Charles E. Redman said the cuts "pose serious risks to our foreign policy and national security interests."

He added that the department will consult Congress to seek ways "to limit damage to our vital interests and meet in a minimally adequate way our commitments and responsibilities as a global power."

Of all countries receiving U.S. security aid, only Israel, which will receive a total aid package of $3 billion, and Egypt, with $2.1 billion, will be funded at the same level as fiscal 1987, according to figures Redman released yesterday.

Funds for Pakistan, the key U.S. ally in Southwest Asia, were cut from a 1987 total of $563.6 million in military assistance and security-related aid to $480.8 million.

Because of the cuts, economic aid to 19 poor Third World countries in Latin America, the Caribbean, Africa and the Pacific region will be eliminated entirely. The administration has contended that aid to these countries serves U.S. security interests by helping to stabilize societies whose poverty, inflation and social inequalities make them prone to upheaval.

Congress last month appropriated about $8 billion for security assistance, which includes three purely military programs: Foreign Military Sales to provide credits for purchase of American weaponry; the Military Assistance Program (MAP) involving the direct, nonreimbursable transfer of U.S. equipment to other countries, and International Military Education and Training Programs.

Also part of security-assistance is the Economic Support Fund (ESF), which offers balance-of-payments support and economic development programs to countries where the United States has security interests. ESF represents the largest share of Agency for International Development programs.

Congress both held down the overall appropriations for these programs and "earmarked" an unprecedented amount for favored recipients. When Congress allocates a set sum to specific countries, the administration loses its discretionary authority to make distribution changes.

Many of the earmarks parallel the amounts the administration had intended to give the recipient countries. But in some areas, particularly in distributing the $3.2 billion appropriated for the Economic Support Fund, earmarking gave two countries -- Israel with $1.2 billion and Egypt with $815 million -- almost two-thirds of the total. When other earmarks are added, only $99 million is left for all other ESF programs.

The MAP program, designed to aid poorer nations that cannot pay for military equipment, would be scrapped for 19 countries that last year received relatively small amounts of $5 million or less.

Countries that would lose all ESF aid are Lebanon, Belize, Dominican Republic, Ecuador, Haiti, Jamaica, Peru, Uruguay, Botswana, Cameroon, Gambia, Madagascar, Mauritius, Mozambique, Niger, Tanzania, Zaire, Zambia and several Eastern Caribbean ministates.