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