Preheat the oven to 375°F (190°C) and butter a medium casserole dish.
In a saucepan over medium heat, melt butter and sauté onion for 3 to 4 minutes until soft.
Add minced garlic and cook for 30 seconds until fragrant.
Pour in heavy cream and milk, then season with salt, black pepper, smoked paprika, and thyme.
Simmer the sauce gently for 3 to 4 minutes without boiling hard.
Layer half of the sliced potatoes in the casserole dish, top with half the ham, then pour half the cream sauce over.
Repeat the layering with remaining potatoes, ham, and sauce.
Cover the dish loosely with foil and bake for 40 minutes.
Remove the foil, evenly sprinkle shredded cheddar and mozzarella on top.
Return the casserole to the oven and bake uncovered for 15 to 20 minutes until cheese is golden and bubbly.
Let the casserole stand for 10 minutes before serving.
Serve hot as a main dish or hearty side.