The ruling means that tax subsidies that make health insurance affordable for low-income individuals can continue.
United Health Group was the best performer on the Dow Jones, up 2.7%, while Tenet Healthcare rose 12%.
Overall though, the main US share indexes closed lower.
The Dow Jones closed down 74 points, or 0.4%, at 17,891.90. The S&P 500 fell 6 points, or 0.3% to 2,102.31 and the tech-heavy Nasdaq slipped 10 points, or 0.2% to 5,112.19.
The failure to find an agreement between Greece and its creditors continued to hang over shares.
In economic news, the latest numbers on US consumer spending showed a monthly increase of 0.9%, the biggest gain in six years and accelerating from April's 0.1% rise.
Personal income increased 0.5%, the same as the previous month.
There was a small increase in the number of people claiming jobless benefits, but the underlying trend still shows a tightening labour market.
Oil and gas producer Magnum Hunter Resources shares rose 6% after it said it expected to raise $600-$700m by selling its 45.5% stake in its natural gas gathering subsidiary, Eureka Hunter Holdings. Its shares had fallen some 44% this year on concerns over its liquidity.
Shares in Nasdaq listed Netflix fell 2% on the news that billionaire investor Carl Icahn had sold his remaining stake in the TV and movie subscription service, in part because he is worried that financial markets are "extremely overheated".
(Close): A supreme court ruling that upheld a key part of President Obama's healthcare plan lifted shares in US health companies.