Preheat oven to 350°F.
In a Dutch oven, melt butter over medium-high heat.
Add onion and cook until softened and lightly browned, about 4 minutes.
Stir in garlic and cook until fragrant, about 30 seconds.
Add cream, milk, thyme, bay leaf, salt, pepper, and potatoes.
Bring to a simmer. Cover and cook until potatoes are nearly tender, about 15 minutes.
Discard thyme sprigs and bay leaf.
Transfer mixture to a 3-quart gratin dish. Sprinkle with cheese.
Bake until cream thickens and top is golden brown, about 20 minutes.
Let rest 5 minutes before serving.