If just a spoonful of sugar helps the medicine go down, imagine how 18 million pounds of sugar exported to the Soviet Union must have helped offset the pain of the grain embargo.

While wheat and feedgrains have been withheld from the Soviet Union since Jan. 4 in response to the Russian invasion of Afghanistan, sugar has been shipped from here to there for the first time ever in a volume equal to half of last year's total exports.

No grand design is at work here, according to Agriculture Department officials. "We just never thought the Soviets would be buying," said one.

The events coincided with a year in which the Soviets were suffering through their second last bad sugar crop and when production in Cuba -- normally a major supplier of the Soviet Union -- also was poor, according to Agriculture Department sugar specialist Robert Barry.

The agricultural embargo is aimed primarily at the Soviet grain-livestock complex. Under its provisions, exports of wheat, corn and other feedstocks have been curtailed severely. but in the meantime, the U.S. agricultural balance of trade has been sweetened by about $4 million in sugar sales.

Under the embargo, sugar was included in a category of commodities which were permitted to be exported under a general license with requirement that embargo monitors at the Department of Commerce be sent copies. "Sugar, to the best of my knowledge, is irrelevant to the purpose of the cutback," said Converse Hettinger, whose office is responsible for licensing embargoed commodities.

The exports took place in a year when world sugar production was generally poor, when U.S. sugar exports have climbed to record-high levels and when the prices consumers are paying for sugar at American grocery stores have nearly doubled.

Sugar exports through August were 365,000 tons and are expected to reach approximately 500,000 tons by the end of the year. Last year's exports were 18,000 tons, and the previous high was 216,000 tons in 1975, said Barry. Most of the sugar exported from the United States is refined.

The U.S. average retail price for sugar in September was 43 cents a pound compared with an average price of 24.9 cents in 1979. Prices are expected to climb even higher.

"Whether we exported or not, prices would be just about this high," said Barry. The United States depends on outside sources for about 40 percent of its sugar, and prices generally reflect world prices, he said.

This year's relatively good sugar production follows several sour years in which prices have been low. In three years, approximately 27 U.S. suger-refining factories have closed.