Federal health officials have learned that Sanofi's heartburn medication Zantac includes an impurity that could cause cancer, the U.S. Food and Drug Administration said Friday.

The probe comes after Valisure, an online pharmacy company, said it alerted the FDA that it found NDMA in Zantac.

The FDA said it has been investigating the carcinogen, called N-nitrosodimethylamine or NDMA, in blood pressure and heart failure medicines since last year and is evaluating whether low levels pose a risk to patients.

"The FDA is not calling for individuals to stop taking ranitidine at this time; however, patients taking prescription ranitidine who wish to discontinue use should talk to their health care professional about other treatment options," the FDA said in the statement.

Ranitidine medicines are used to treat stomach acidity and heartburn and are both over-the-counter and prescription drugs.

"Sanofi takes patient safety seriously, and we are committed to working with the FDA," Sanofi told CNBC in a written statement. The Zantac over-the-counter medication "has been around for over a decade and meets all the specified safety requirements for use in the OTC market."

The FDA said that although NDMA may cause harm in large amounts, the levels it is finding from preliminary tests aren't much higher than what's found in common foods.

Valisure filed a petition with the FDA asking it to recall and suspend sales of ranitidine.

"Every manufacturer and every type of Zantac or ranitidine that we've analyzed seems to have the same problem of the drug itself being very unstable and degrading, or even potentially reacting to, the condition in the human stomach to create NDMA," said David Light, CEO of Valisure.

Light said the pharmacy company analyzes samples of every batch of every medicine it dispenses, and that it adopted analytical techniques recommended by the FDA to screen for NDMA and N-Nitrosodiethylamine or NDEA, another carcinogen.

"We've been trying to be very proactive in terms of not just looking where everyone else is looking," Light said.