General Telephone & Electronics Corp. yesterday reported earnings gains of 13 percent for the second quarter and 12 percent for the first half.

Chairman Theodore F. Brophy said both telephone operations and the communications products manufacturing business did well in spite of the recession.

Net income for the quarter was $299.99 million ($1.14 a share) on revenues of $3.035 billion compared with $178.38 million ($1.08) a year earlier on revenues of $2.672 billion.

First-half profits were $398.95 million ($2.28) on revenues of $5.932 billion compared with $356.74 million ($2.18) a year earlier on revenues of $5.239 billion.

Telephone profits were up 17 percent in the second quarter on a 20 percent rise in revenues. Second-quarter profits on communications products also were up 17 percent, but sales and earnings on ordinary electrical products were down a little.

In spite of substantial losses on foreign currency translations, Safeway Stores Inc., the nation's largest supermarket chain, earned $42.1 million ($1.61 a share) in the second quarter, up from $26.2 million ($1.00) a year earlier, as sales increased to $4.045 billion from $3.781 billion.

First-half profits were $58.1 million ($2.22 a share) on sales of $8.029 billion compared with $45.47 million ($1.74) a year earlier on sales of $7.37 billion.

Sales were affected adversely by the closure of the Omaha division. The company said this closure and continuing foreign exchange losses will reduce third-quarter results.

J.P. Morgan & Co. Inc. yesterday reported flat earnings in the second quarter, a fallout from an extraordinary gain the previous year. Excluding this, Morgan's earnings would have increased 19.2 percent.

Morgan, whose principal subsidiary is Morgan Guaranty Trust bank, had income before securities transactions of $98.8 million in the second quarter compared with $98.6 million in the 1981 quarter. Earnings per share were $2.35 in both periods.

In the first half, Morgan's operating earnings rose 10.4 percent to $196.3 million ($4.76 a share) from $177.8 million ($4.33) in the first half of 1981.