Declining food prices and a slowdown in energy costs held the June increase in consumer prices to just 0.2 percent and brought the annual inflation rate to its lowest level in more than 15 years, the government reported yesterday.

In the 12 months ending in June, consumer prices rose by a mere 2.6 percent, the Labor Department said. This was the smallest 12-month increase since October 1967.

President Reagan welcomed the inflation news, which follows a string of good economic reports in recent days. He said the June consumer price index shows "that a healthy economic recovery is under way." Together with Thursday's report that the nation's economy grew at an annual rate of 8.7 percent in the second quarter, the inflation numbers are "clear evidence that our program and the American economy are on the right track," Reagan said.

However, the adminstration does not expect inflation to stay at the low levels recorded last month. Most analysts, including those in the White House, predict inflation will run between 4 and 5 percent for 1983 and 1984.

Treasury Secretary Donald T. Regan cautioned this week that the two elements holding down the June inflation numbers--food prices and energy costs--could change as a result of the current heat wave. Extremely hot weather typically damages crops and pushes up food prices, he said. In June, food prices dropped by 0.3 percent, the Labor Department report said. Heavy use of air-conditioning during the heat wave also could lead to upward pressure on energy prices.

Energy prices rose sharply in the second quarter of this year, but the June increase was considerably smaller than those in April and May, thus contributing to the lower inflation rate last month, the Labor Department said. Gasoline prices rose 0.7 percent in June after climbing a total of 8.3 percent during April and May.

For the second quarter as a whole, the transportation index advanced at an annual rate of 11.7 percent, reflecting the rebound in oil prices after their declines early in the year and the imposition of a 5-cents-a-gallon excise tax on gasoline. This increase compared with an annual rate decline of 8.9 percent in the costs during the first three months of 1983.

The buildup in energy prices was largely responsible for a marked acceleration in consumer price inflation between the first and second quarters of 1983, the report said.

The annualized inflation rate for January to March was only 0.4 percent, while in the second quarter this rate climbed to 5.4 percent. For the first six months as a whole, inflation measured 2.9 percent at an annual rate.

Despite the slowdown in inflation, interest rates remain high, and presidential economist Martin Feldstein said this week that the key prime rate charged by major banks could rise at any time. He said that it would be better to have this rise than to risk more inflation in the future through allowing excessive monetary growth. The recent climb in interest rates has come largely as a result of a mild credit tightening by the Federal Reserve Board in reaction to recent rapid increases in the money supply.

Slower inflation has helped to boost the standard of living, although last month real earnings, measured after accounting for inflation, climbed by just 0.1 percent, the Labor Department reported. These earnings had risen by 0.5 percent in May and 0.2 percent in April.

Consumer prices rose by 0.5 percent in May and 0.6 percent in April after seasonal adjustment, the report said.

The consumer price index stood at 298.1 in June (with 1967 as 100) before seasonal adjustment. This means a basket of goods costing $100 in 1967 cost $298.10 last month.

Yesterday's price report also showed that medical care costs, which have risen very rapidly in recent years, continued upward but on a slower path, with a 0.5 percent increase in June. In the past year, these costs have climbed by 8.9 percent.

In a separate report yesterday, the Commerce Department said that orders for big-ticket items jumped by 5 1/2 percent in June to $89.5 billion. However, increases in defense orders accounted for much of the improvement. Orders for nondefense durable goods rose by 1.2 percent, while machinery orders declined, the report said.