Herz has irregular singular declension and is the only noun of its kind.
Thegenitive singular takes the ending-ens:des Herzens. The formdes Herzes is less common and only used in medicine.
Thedative singular traditionally takes-en:dem Herzen. This form is still the only accepted standard form in many—more or less fixed—expressions, such asim Herzen,von Herzen,zu Herzen,Operationam offenen Herzen(“open-heart surgery”),mit halbem Herzen(“half-heartedly”), and others.
Only the bare formdem Herz is common when referring to a cardsuit, as a term of endearment, and in the phrasemit Herz(“good-hearted”).
Otherwise, the formsdem Herzen anddem Herz are both acceptable. The latter is predominant in speech, while the former remains the more established form in writing.