Preheat the oven to 375°F. Slice ½ inch of the tops of the garlic heads off so that the cloves are exposed. Place on a large piece of tin foil. Drizzle with olive oil and season with salt.
Wrap the tin foil around the heads of garlic and place on a baking sheet. Bake for 45-50 minutes or until the cloves are caramelized. Allow to cool slightly and then squeeze the cloves out into a medium pot. Spoon out a few of the cloves and reserve for later.
Mash the remaining roasted garlic into a paste and then place the pot over medium heat. Add in the half-and-half and thyme, stirring well to incorporate the garlic paste. Season with a little salt and pepper.
Bring the mixture to a simmer and then reduce the heat to low. Simmer for about 20 minutes.
Meanwhile, slice the potatoes very thinly using a mandoline or a very sharp knife. Arrange roughly a third of the potatoes on the bottom of a buttered 9 x 13-inch baking dish. Top with a handful of the shredded cheeses and then drizzle some of the garlic cream over top.
Repeat this process two more times until all the ingredients have been used up, ending with an extra handful of cheese on top. Scatter the reserved roasted garlic cloves over the top of the cheese.
Gently press everything down to ensure that the potatoes are submerged in the garlic cream.
Place the baking dish on a baking sheet and bake for 1½-2 hours, or until a knife easily inserts through the potatoes in the center. Allow to cool for at least 20 minutes before serving.
To make ahead, the gratin can be assembled completely and kept covered in the fridge for a day or two. Allow it to return to room temperature before baking.