It was a fruitful year for the rank and file at oil-and-gas companies, from Exxon Mobil Corp. to Phillips 66.

Oil-and-gas drillers and refiners had some of the highest-paid median workers in the energy and utility sectors in 2018, according to The Wall Street Journal analysis of annual pay disclosures for hundreds of big U.S. companies as provided by MyLogIQ.

Houston-based...