Occidental Petroleum Corp., the first of the nation's major oil companies to announce second-quarter profits, reported yesterday a sharp turnaround from steep losses last year.

With petroleum firms under fire for so-called "excess profits" - from the White House and elsewhere - Occidental said yesterday that increased earnings from oil production in the North Sea, Peru and Libya helped boost the Los Angeles firm's second-quarter profits to $112.5 million ($1.33 a share) compared with a loss of $68 million in the same quarter last year.

Oxy Pete's earnings in the 1978 period were unusually depressed in connection with writing down refinery investments in Britain and Belgium by $122 million. Indeed, of the 26 largest oil firms surveyed for a Washington Post series last May, Occidental had the worst performance in 1978 - profits of $7 million on sales of $6.25 billion.

A better measure of Occidental results in the second quarter is earnings from oil and gas prior to the $122 million writeoff. In the recent three months, Occidental's oil and gas earnings were $127 million compared with $38 million in the 1978 period.

Sales for the second quarter rose sharply to $2.2 billion from $1.6 billion a year ago, with much of the increase reflecting higher crude oil prices.

For the first half of 1979, Oxy Pete profits were $200 million ($2.35 a share) compared with a loss in 1978 of $36 million as sales soared to $4.1 billion from $2.8 billion.

In addition to increased production and better profit margins from petroleum operations in the North Sea, Peru and Libya, an Occidental spokesman said yesterday that the company also benefited from elimination of retining losses and from lower marine losses.

An Oxy subsidiary, Hooker Chemical Co., reported lower profits because of costs related to environmental problems that surfaced in connection with "past practices" - an apparent reference to pollution in the Love Canal, an old Hooker site near Buffalo. Profits of another subsidiary, Island Creek Coal Co., also were lower because of higher labor and production costs that could "not be recovered in a depressed spot market."

Generally, Wall Street analysts are expecting oil company earnings statements to be rosey not only for the quarter just ended but for all of 1979 - in part a rebound from relatively lower earnings levels of earlier years. However, a recession is expected to depress oil company profits from their investments in coal, chemicals and metals.

Analysts at Drexel Burnham Lambert in New York, in a mid-year review, forecast oil firm profits will rise "strongly" in 1979 and possibly again in 1980. When compared with recession-dominated prospects for overall corporate profits, the oil industry's outlook is "superior", the analysts said.

The principal source of profit increases this year and next will be in higher profit margins, particularly from U.S. production, according to the Drexel Burnham analysis.

But rising oil prices also mean higher working capital requirements and outlays for expansion will remain in "high gear," they said. Oxy noted yesterday, for example, that capital expenditures in the first six months of 1979 rose to $357 million from $344 million in the same period last year.