A Heart Container increases a character's HP, permanently, by the same amount of HP that a character would gain from gaining a level - so a Ranger who gets a Heart Container would gain 5 HP, while a Paladin would gain 6, and a Wizard would gain 4.
Heart Containers serve to replace the gaining of HP at level-up. Heart Pieces serve to replace the Toughness feat.
Heart Containers are generally gained in one of two ways:
As a reward for righteously defeating defeating horrific, evil monsters - the kind that guard ancient temples, or wellsprings of power, or lead armies of darkness.
Assembling Heart Pieces, hidden away in the secret places of the world, or guarded by lesser evils.
Both methods require some minor modifications to the rules of D&D as currently written. Each method may be used on its own, or you may use both simultaneously.
If characters are to gain Heart Containers when they defeat evil forces, then to keep their HP totals in line with what the game expects, they may not gain HP as they level up. (All other statistics, powers, and feats are gained as normal through leveling up - the only difference is that a character's HP total does not increase upon leveling up.)
Instead of gaining HP upon leveling up, the characters will simply gain Heart Containers at a pace that roughly matches that of leveling up - a Heart Container should be given to a character roughly once a level, resulting in a total HP that would match that of the character in a game without Heart Containers, plus or minus one to two levels' worth (at the most!).
If your campaign chooses this method, then be aware that it requires much oversight from the DM, to make sure that characters have an appropriate amount of HP for their level. It is suggested that the DM keep track of how many Heart Containers each character has received, compared to his or her level, and dispense Heart Containers, healing items, or (potentially) Heart Pieces as appropriate.
It is suggested that the DM simply give each character a Heart Container upon the defeat of an appropriate monster, both for ease of book-keeping, to prevent a player from attempting to horde Heart Containers, and to provide everyone an appropriate reward for their accomplishment.
It takes four Heart Pieces to create a Heart Container. Alternatively, it may take five. However many Heart Pieces comprise a Heart Container, upon assembly, the Heart Container bestows its benefit (above), which consumes the Heart Pieces.
Heart Pieces are typically hidden in small, dangerous areas of the world, guarded by puzzles or monsters that require specific skills, tactics, spells, or abilities to defeat or circumvent. Such places may be hidden away in other, larger complexes - a lost vault beneath the duke's castle, - or they may be standalone areas of interest with no relation to the world (and its events) at large - a mountain cave on the pass leading to the Orc tribes. These areas should have the approximate structure of a Dungeon Delve: 2-4 areas, each with its own small challenge, and potentially a larger challenge mixed in to keep players on their toes. This means that gaining a Heart Piece should take a character, at most, halfway to their next level.
If your campaign chooses this method, disallow the Toughness feat. (If a character would gain the Toughness feat for free, IE by being a two-weapon Ranger, allow the character to choose a different feat to replace it as appropriate.) As Heart Pieces will allow the character to gain approximately the same amount of HP at the same rate, the use of Heart Pieces basically gives a character the Toughness feat for 'free' - excepting all the Delves, full of puzzles and monsters, that they must go through to obtain them.
As Heart Pieces replace the Toughness feat, be sure that no player gains enough Heart Pieces to make more than one Heart Container per tier. If players spread the Heart Pieces out among themselves, the DM may provide enough (or enough opportunities) to allow each character to form a full Heart Container per tier; if one player hordes Heart Pieces, the DM should limit the chances for Heart Pieces so that there will only be enough Heart Pieces for that character to for a single Heart Container during that tier of play.
Unlike Heart Containers, which should be distributed strictly evenly and at a strict pace, a DM need not worry quite so much about Heart Pieces. While a DM can give each player a Heart Piece upon the completion of its guardian puzzles and monsters, it is not necessary - this comes down to a decision concerning your group's preferred style, rather than one of strict balance.