Preheat oven to 475 degrees.
Put roast, ribs side down, in center of a 13 by 9 inch flameproof roasting pan and rub all over with 1/2 tablespoon oil. Cut about 1/2-inch from tops of garlic heads to expose cloves and discard tops. Rub beef all over with cut sides of garlic and sprinkle with 2 tablespoons thyme, pressing to adhere. Season beef generously with salt and pepper. Put garlic heads on a double layer of foil and drizzle with remaining 1/2 tablespoon oil. Wrap garlic tightly in foil.
Roast beef in middle of oven 30 minutes. Remove beef from oven and with a bulb baster skim all but about 1/2 cup fat from pan. Baste beef with fat remaining in pan.
Reduce temperature to 375 degrees.
Add garlic to oven. Roast beef, with garlic, 1 1/4 to 1 1/2 hours more, or until a meat thermometer inserted into center of meat registers 115 degrees. Transfer garlic in foil to a rack and transfer beef to a platter, reserving pan juices. Let beef stand 25 minutes. (Meat will continue to cook reaching about 130 degrees for medium-rare.)
While beef is standing, remove all but about 2 tablespoons fat from pan. Add shallot to pan and on top of stove cook over moderate heat, stirring, 2 minutes. Unwrap garlic. Protecting your hand with a double paper towel, squeeze roasted garlic into shallot mixture and discard skins. Add vinegar, wine, bay leaf, and remaining tablespoon thyme and boil mixture, scraping up browned bits and mashing garlic with a wooden spatula against bottom of pan, until reduced to about 1/2 cup, about 5 minutes.
If using demiglace, stir into garlic mixture and boil sauce until reduced to about 2 cups, about 5 minutes. Whisk in butter. If using beef broth, in a small bowl mash together butter and flour to make a beurre manie. Stir beef broth into garlic mixture and boil sauce until reduced to about 2 cups. Whisk beurre manie into broth mixture and cook over moderate heat, whisking, until sauce is smooth and slightly thickened, about 3 minutes. Pour sauce through a fine sieve into a bowl, pressing hard on solids. Season with salt and pepper.
Cut rib roast into slices and serve with sauce