Put oven rack in middle position and preheat oven to 425°F.
Cut off and discard 1/2 inch from tops of garlic heads, exposing cloves. Put garlic in a pie plate with oil, herbs, salt, and pepper and cover plate tightly with a double layer of foil. Roast until garlic is golden and tender, 1 to 1 1/4 hours.
When garlic is cool enough to handle, squeeze cloves into a bowl and pour oil through a fine-mesh sieve onto garlic. Mash well with a fork and season with salt.