Lex Luthor is occasionally known for heroics, if only to further his own schemes.
Does he ever have to defeat Superman to save the universe, the world, Metropolis, Lois Lane, etc.?
I'm not really a comic book person, but there are a few TV and game based examples that I can think of.
Note: where I mention a "prime" of something, it's in reference to the primary universe or timeline that the DC superheroes we know and love inhabit.
A standalone animated movie where a heroic Lex Luthor from an alternate universe travels to the "prime" universe to recruit the Justice League against his battle with his version of "superheros" called the Crime Syndicate. Bonus: the alternate Joker appears (called the Jester) and is also a hero.
This episode from the Justice League TV series shows an alternate universe version of the Justice League called the Justice Lords, who discover the prime universe. They decide based on their own past that the Justice League are naive and incompetent. They decide to swing by for a visit to educate the Justice League in their "more effective" methods of crime fighting or to enforce it themselves. Prime Lex Luthor ends up being recruited by prime Superman to help stop the Justice Lord Superman.
Injustice: Gods Among Us and Injustice 2 (as well as a supporting comic series) focus mainly on an alternate universe Superman that was involved in a horrific event largely out of his control. As a result of this event and some (in hindsight) not-so-great consoling and advice from the, uhh, more "militant" superheroes near him, alternate Superman becomes much more heavy-handed when dispensing justice, to the point that he becomes a tyrant in charge of a world-wide government. Lex Luthor's role in this story is a bit more complicated.
Alternate Superman considers him to be loyal and a dependable friend, but he's actually a mole for that universe's insurgency against Superman's regime. He eventually reveals himself and fights against Superman.
Several heroes from the prime universe also make an appearance in the first game, which includes some Superman vs Superman action. Prime Lex Luthor does not appear at all.
There is also at least one animated movie I can think of where Lex Luthor is a hero but does not actually have a conflict with Superman.
This animated movie focuses on the Flash and his actions. After the Flash accidentally screws up the timeline, this alternate timeline Lex Luthor is a hero who is fighting against the militaristic goals of Atlantis and the Amazons (who are also fighting each other). The ship that Lex utilizes in the movie strongly resembles a US military ship, but it's not clear if he's acting on behalf of some group or government. Superman's role in this movie is actually quite minor as a result of the changes to the timeline, and the two never interact.
Yes, in Superman: Red Son Lex Luthor saves the world from communist Superman