The United States ran its smallest trade deficit in seven months in May, in largest part because of a steep decline in steel imports as an administration program to protect the domestic steel industry went into full effect.

The Commerce Department reported that the trade deficit was $2.24 billion in May compared with $2.86 billion in April. It was the smallest amount of red ink in the nation's trade ledger since imports exceeded exports by $1.9 billion last October.

Nonetheless, the United States has now recorded a deficit in its trade with other nations for 24 consecutive months.

The dollar improved slightly in Europe and Japan on the news.

William Cox, deputy chief economist for the May deficit is a "basis for preliminary encouragement." He noted that exports continued to grow after a large, 17 percent jump between February and April. "That is an indication that the strong growth in imports was not a flash in the pan," he said.

"Even more encouraging," Cox said, was the decline in imports. Steel imports declined $265 million while automobile imports fell $260 million. He said the decline in steel imports probably reflected both the imposition of the administration's minimum price program for steel imports as well as a natural "inventory correction" following four months of heavy steel imports this year.

Many steel importers sought to beat the imposition of the Treasury's so-called trigger price program by importing large quantities of the metal before the full program took effect April 30. While steel imports in May were 30 percent below April (and 17 percent higher during the first five months of 1978 than in the first five months in 1977.

Similarly, Cox said, the decline in auto imports probably reflects a big build up in inventories by dealers who tried to beat the impact of the sharply rising value of the Japanese yen.

The U.S. exported $11.75 billion last month and imported $13.99 billion. Exports rose about $120 million while imports fell about $510 million.

Cox said he expects the size of the trade deficits to decline throughout the year and the nation to run a yearly deficit about as large as last year's $26.5 billion. For the first five months of 1977 the deficit was $8.24 billion, while this year it is $14.77 billion.

The dollar has declined sharply in the past year in part because Americans continue to buy billions of dollars more of foreign goods than the amount of U.S. products purchased by foreigners. That puts more dollars into the world's economy than foreigners want, making the dollars value fall.

Because the dollar can buy less of a foreign currency, import prices rise. The administration estimates that the decline in the dollar will add half a percent to the infation rate this year.

Despite the big decline in steel imports, steel industry officials remained unhappy. According to the trade association, the American Iron and Steel Institute, steel imports werer down 30 percent from April, to 1.51 million tons from 2.18 million tons.

For the first five months of the year, however, steel imports totalled 9.43 million tons, compared with 6.23 million tons last year, a 51 percent increase.

Frederick Langerberg, president of the American Iron and Steel Institute, said the most steel industry officials are "alarmed and surprised" that the May imports "were as high as they were. We though they would be closer to 1 million tons."

But Peter Ehrenhaft, deputy assistant secretary of the Treasury for tariff affairs, said that many of the imports recorded in May actually landed in the U.S. in April, but the import documents were delayed in reaching the Customs Service until the first week in May.

Ehrenhaft said that he expects the June imports of steel will be lower still.

Langerberg said the administration is "running out of excuses" for why it cannot reduce steel imports.

The administration program sets minimum prices for steel imports based on the costs of the world's most efficient producer, Japan. If steel is imported into the country below the trigger prices, the Treasury is supposed to launch a expedited anti-dumping investigation to determine if the steel is being sold at less than fair value.

Selling products at less than fair value is against U.S. trade laws, but generally anti-dumping investigations take 15 months to complete. The Treasury's special program for steel is supposed to reduce the investigation time to six months and the publised trigger prices give importers a ground from which to decide whether they will be accused of dumping.

Treasury sources said that of the "tens of thousands" of steel shipments in May, they have identified five instances in which steel which steel was imported below the trigger prices and are now investigating to see if anti-dumping investigation should be launched.

Langerberg said that it now seems impossible to hold steel imports to the 14 million ton level first suggested when the administration's plan was outlined early this year. He said steel imports will likely be near the record 19 million ton level last year.

In another development, an analysis presented to a meeting of the congressional steel caucus yesterday, said that if the U.S. cuts tariffs on its steel imports by 39 percent, as it reportdly has offered to do at the multilateral trade talks now being held in Geneva, U.S. steelmakers could see their profits per ton fall by a half. The analysis was done by the Iron and Steel Institute.

U.S. officials say privately the assertion by Lewis Foy, chairman of the Bethlehem Steel Corp., that the nation's trade negotiators have made such an offer is wrong, but they decline to say how much the nation is willing to cut steel tariffs.

U.S. officials deny this country has offered a 39 percent tariff cut, but they decline to say how much the nation is willing to cut steel tariffs.