The highest oil prices in years are increasing expenses for companies that had grown used to low energy costs since crude’s 2014 tumble, while the turnabout is proving to be a boon for some businesses.

Giant outfits from American Airlines Group Inc. to 3M Co. have warned this week about how persistent higher oil prices are boosting their expenses this year.

In...