The Soviet Union reported today that its oil and natural gas production reached record levels during the first half of this year, with oil production averaging 12.04 million barrels a day.

The report came one day after Moscow reached a preliminary agreement with West German commercial banks on joint construction of a controversial 3,000-mile pipeline to bring natural gas from Siberia to Western Europe, with a $4 billion West German participation. The $10 billion project is regarded as crucial for future development of Soviet energy sources.

Soviet energy figures are closely watched by diplomatic analysts here because of their possible implications for Soviet policy toward the oil-producing regions of the Middle East.

A decline in oil production at a time when Soviet energy needs are growing could lead Moscow to complete actively for access to Arab and perhaps Iranian oil. A U.S. Central Intelligence Agency study forecast recently that Soviet oil production would peak at 11.9 million barrels a day in 1980 and then decline to 9 million barrels a day by 1985.

By comparison, the world's largest oil exporter, Saudi Arabia, produces about 10 million barrels a day. Although the Saudis export nearly all their production, the Soviets must meet the vast energy needs of their own economy as well as those of their allies.

The statistics announced today showed natural gas production this year rose by 7 percent, to 228 billion cubic meters. But coal production slipped slightly to 360 million tons from 362 million the year before, according to the official figures.

Some Soviet analysts privately indicate that they expect oil production to decline in the near future because traditional reserves in European Russia and Transcaucasus are being depleted. In this context, the development of Siberian resources is regarded as vital for the Soviet economy and the proposed pipeline is a major step in that direction.

Soviet concern on this score was reflected in a statement by Deputy Premier Guriy Marchuk, who was quoted this week as saying that "almost three-fourths of the entire mineral, fuel and energy resources of the country are concentrated in Siberia," which at this stage generates "about 10 percent of the national income," the rough Soviet equivalent of gross national product.

Becuase of lack of capital, the Soviets have sought to involve Western nations in the pipeline project, which also will include the first major development of infrastructure in the largely barren region. The United States has opposed this on grounds that the project would make Western Europe dependent on Soviet energy supplies.

Today, the Soviets expressed gratification with the West German decision by saying that the Bonn government and other Western governments have refused to join President Reagan's "economic war" against the Soviet Union.

"Trade with Moscow will not be blocked," a Novosti press agency commentary said. "Siberian gas will come to Western Europe."

While the energy figures were encouraging, the overall performance of the Soviet economy revealed problems in various sectors. Production was well below target, rising only 3.4 percent over comparable figures for the past year. Productivity increased by 2.6 percent, below the target of 3.6 percent.