Hearts are collected from killing monsters and restore some health upon being eaten. Some weapons are more adept at collecting heart than others, and some weapons cannot collect hearts at all. The exact stats of this can be found on the Weapons page.
Hearts can be collected from all manner of monsters, and the exact amount of health restored seems to be independent of the type of heart collected. And although not specified, hearts have levels, with the higher levels restoring more health, but the amount restored is seemingly random.