Major U.S. stock indexes shook off a slide in health-care shares and closed higher Wednesday.

In a choppy session, stocks rose heading into President-elect Donald Trump’s first news conference since the election, then dipped into negative territory during the event before recovering in the afternoon.

The Dow Jones Industrial Average swung...