The de Blasio administration has ordered two mohels to stop performing “unsafe” ritual circumcisions after they were linked to herpes cases in infants — but, in a baffling move, it’s keeping their names secret.

Mayor de Blasio defended the new policy, claiming there are legal limitations on what the city can do.

“As far as we understand legally at this moment, because of confidentiality rules relating to someone’s health status, we can’t publish the names overtly,” he said.

“We are looking for some pathway to do that that’s appropriate. We can certainly tell those individuals they should stop participating in this practice and unfortunately once they have herpes, it doesn’t go away.”

Mohels who practice the ancient ritual of metzitzah b’peh are believed responsible for six cases of neonatal herpes over the last two years.

During the procedure, the mohel sucks blood away from the wound of an infant’s penis after circumcision.

Health Commissioner Dr. Mary Travis Bassett told a City Council hearing Wednesday that “the department considers this an unsafe practice and we recommend that people not engage in it.”

But she added that metzitzah b’peh is a religious practice with legal protections that does not have to be performed by a licensed practitioner.

“The medical view is different than the spiritual view,” Bassett said.

Health officials said mohels ordered not to perform any more of the high-risk circumcisions face a $2,000 fine if they violate the order. They are not barred from performing regular circumcisions.

During the 2013 mayoral campaign, De Blasio won support in Brooklyn’s Orthodox Jewish community by promising to scrap an unpopular Bloomberg-era rule that required parents to sign a consent form that explained the medical risks of the metzitzah b’peh.

In February 2015, de Blasio announced a deal with a rabbinical coalition to turn over mohels linked to herpes so they could undergo testing, in return for scrapping the consent form.

The agreement was voluntary — and unenforceable.

De Blasio, who said the community simply ignored the Bloomberg consent form, admitted Wednesday that his policy, too, was a bust.

“We tried a new policy; it didn’t work either, which I’m very unhappy about . . . I’m not happy about the outcome and I don’t think those community leaders did all they could have,” he said.

When one reporter asked if it was “ever appropriate” for an adult to suck the penis of an infant, the mayor pointed to constitutional protections of religious activity.

De Blasio said the city is now going to focus on educating parents to grill mohels.