In large pot, combine cream, milk, garlic, onion, 5 sprigs thyme, bay leaves (if using), salt and nutmeg. Bring to a low boil over medium heat; remove from heat and cover. Let stand for 45 minutes.
Bring cream mixture back to a low boil over medium heat for 5 minutes, then strain into a large bowl.
Preheat oven to 350°F. Meanwhile, peel and, using a mandoline, slice potatoes into slices that are ⅛ in (3 mm) thick and add to cream mixture, stirring to prevent them from sticking together.
In bowl, combine Gruyère and Parmesan cheeses. Set aside.
Spread butter on bottom and up sides of 2-L baking dish. Layer one-quarter of the potatoes, overlapping them; sprinkle one-third of the cheese mixture overtop and sprinkle with ¼ tsp of the pepper. Repeat two more times, setting the extra cheese aside. Pour remaining cream mixture overtop and then sprinkle over the remaining ¼ tsp pepper.
Tightly cover with aluminum foil; place on baking sheet and bake for 60 to 70 minutes. Remove foil; sprinkle with remaining cheese mixture and return to oven. Bake until potatoes are tender and top is golden brown, 20 to 25 minutes. Broil for 2 to 3 minutes for a deeper browning, if desired. Let rest for at least 30 minutes before serving.