Samsung Electronics Co., Apple Inc., and other tech giants have become major players in digital health care by connecting their software to standard medical devices like heart monitors.

Now, the government must regulate these companies’ computer code.

The Food and Drug Administration is working with major tech companies to figure out how to regulate the computer software used in doctors offices and hospitals. The computer code that classifies a patient’s heart activity as normal, for example, should be subject to the same FDA review as a low-risk medical device, the agency says.

The software programs at issue are used in...