A surge in consumer spending boosted retail sales a strong 2.1 percent last month, underscoring the current rapid pace of the economic recovery, the Commerce Department reported yesterday.

Inflation, as measured by the producer price index for finished goods, remained distinctly modest in May, despite the strength of sales. The Labor Department said finished-goods prices rose a seasonally adjusted 0.3 percent, primarily as a result of higher prices for gasoline and home heating oil.

Retail sales increased $2 billion to a seasonally adjusted level of $96.9 billion, the largest gain in a year and the third month in a row with an increase of 1 1/2 percent or more.

Forecasters have been revising their expectations for this quarter steadily upward, with many now saying the economy is growing at an annual rate of 6 percent or more. Commerce Secretary Malcolm Baldrige said that the retail sales figures indicate "that growth in gross national product will be substantially faster and better balanced this quarter than in the first quarter, when GNP, adjusted for inflation, rose at a 2 1/2 percent rate.

Meanwhile, the Conference Board, a business research group, said its consumer confidence index rose for the fifth month in a row. Economist Fabian Linden, head of the board's consumer research center, said the continued rise in the index "points to a far more robust recovery than has been projected by most professional forecasters."

Nevertheless, the survey of 5,000 households also found that, while plans to buy major appliances rose last month, intentions to buy automobiles and homes declined. Almost half the households described current business conditions as "bad."

Noting these cross-currents in consumer attitudes, and the already low personal savings rate, some analysts caution that the month-to-month increases in consumer spending will taper off substantially as the year progresses. Other forecasters believe, to the contrary, that the July 1 cut in personal income tax withholding will keep consumer outlays rising in healthy fashion.

Last month, the spending increase was divided almost evenly between the automotive sector and other types of businesses--about $1 billion each. Sales by automobile dealers rose 5.2 percent and were at a level 16.6 percent higher than a year ago.

The 0.3 percent increase in finished-goods prices left that index 2.3 percent higher than in May 1982.

Prices for fuel rose 2.2 percent, though almost all of that change included prices that went up in April but that are entered into the index with a one-month lag due to late reporting. Prices went up 6.4 percent for home heating oil and 2.3 percent for gasoline, the department's Bureau of Labor Statistics said.

Consumer food prices, on the other hand, fell 0.5 percent following a 1.2 percent increase the month before. Prices for beef, veal and fresh fruits went down after rising sharply in April, and pork prices fell more than they did a month earlier.

Prices of finished consumer goods other than energy and foods rose only 0.1 percent. Prices for cosmetics, textile house furnishings and household flatware increased substantially. Passenger car prices also rose 0.2 percent after falling 1.9 percent in April. Prices for tobacco products and several other consumer goods fell.

Capital goods prices rose 0.2 percent as the cost of some items that fell in April went back up, among them railroad equipment, machine tools and mining machinery.

Producer prices for intermediate goods such as flour, industrial chemicals and lumber rose 0.4 percent, the largest increase in more than a year. Prices of crude goods were unchanged, as declining prices for foodstuffs and feedstuffs offset a 1.4 percent rise in the prices of other crude goods such as metal scrap, cotton and hides.