Exxon Corp., the world's largest oil company, yesterday reported an unexpected 77.2 percent surge in second-quarter profits -- but the entire increase and then some was due to foreign exchange gains from a stronger U.S. dollar.

Exxon's earnings from operations fell 13.3 percent, from $1.554 billion in the second quarter of 1980 to $1.347 billion this year. Improved income from U.S. oil and gas operations, up $111 million to $644 million, was more than offset by a $286 million drop in such income from foreign activities. m

Separately, Standard Oil Co. of Indiana (Amoco), the sixth-largest U.S. refiner, which has a much larger proportion of its business in this country than Exxon, logged a 13.2 percent earnings gain for the quarter.

Conoco Inc., ranked No. 9 and the object of a heated takeover battle, had a 36.4 percent drop in second-quarter operating earnings, to $158.7 million ($1.54 a share) from $249.6 million ($2.32) a year earlier, primarily because of the 72-day coal strike. Revenues were up 4.2 percent to $4.9 billion, against $4.7 billion.

Conoco had an extraordinary $881.3 million gain from the sale of its stake in Hudson's Bay Oil and Gas, which boosted its second-quarter net profits to $1.04 billion ($10.09).

Standard Oil Co. of Ohio (Sohio) said its second-quarter earnings rose from $451.3 million last year to $478.7 million this year. Its sales climbed from $2.84 billion to $2.91 billion. For the first half of the year, Sohio earned $999.1 million ($4.06 a share) on sales of $6.03 billion. In the first half of 1980, earnings were $902 million ($3.67) on sales of $5.5 billion.

The strong showing by Exxon, the largest corporation in the world, came as a surprise in the midst of the world oil glut, but only because most analysts had overlooked the impact of the stronger dollar.

The Financial Accounting Standards Board procedures require that a U.S. corporation count as a gain or loss any change in their foreign liabilities in dollar terms. Thus, if the value of the dollar rises relative to the French franc and a company has borrowed, say, $100 million in French francs to build a plant in France, and the value of the dollar rises, the size of that liability is reduced -- at least on paper. Corporate officials complain that no offsetting loss -- or gain if the dollar declines -- can be recorded for changes in value of the plant in dollar terms.

Analysts had predicted U.S. oil firms would report second-quarter earnings declines of 8 percent to 10 percent below year-earlier levels, because of the profit pinch on refining and marketing petroleum products caused by weak demand.

In the April-to-June period, Exxon earned $1.82 billion ($2.11 a share) compared with $1.03 billion ($1.18) in the 1980 second quarter. Revenues rose 4.7 percent to $27.4 billion, versus $26.2 billion.

Exxon's second-quarter U.S. refining and marketing earnings climbed 72 percent to $50 million, following losses in the two previous quarters. Profits from U.S. crude oil and natural gas production rose 17.8 percent to $594 million.