Heat oven to 350 degrees. Butter a 9x13 baking dish and set aside.
n a medium-size pot, melt butter. Add onion and cook for 5 minutes until translucent. Add garlic and cook for 1 minute. Sprinkle in flour, stir to combine, and continue to cook for 1-2 minutes.
Carefully pour in the stock and whisk to combine with flour mixture. Add in the milk, salt, and pepper, whisking all together. Bring the mixture up to a simmer and continue to whisk until sauce has thickened. Remove from heat.
Layer half of the potatoes and half the ham in the prepared dish. Sprinkle on half of the thyme and Parmesan cheese. Ladle over half of sauce and repeat layer of potatoes, ham, remaining sauce, thyme, and cheese. Cover with foil and bake for 30 minutes.
Remove foil and continue to cook for 30 minutes until bubbly around the edges. Set oven to broil and cook for 1 to 2 minutes until potatoes are golden brown on the top.
Remove from the oven and let rest for 10 minutes. Season with additional salt and pepper if desired and serve.
Notes
Recipe Variations:
Extra cheesy – Top with shredded cheddar, mozzarella, or Gruyère before baking.
Make it vegetarian – Omit the ham and use chopped vegetables like broccoli, carrots, or mushrooms.
Use sweet potatoes – For a slightly sweet, savory twist.
Make Ahead:Assemble the casserole up to 1 day in advance, cover tightly, and refrigerate. Let it sit at room temperature while the oven preheats, then bake as directed.How To Store:Store leftovers in an airtight container in the fridge for up to 4 days. Reheat in the oven or microwave until warmed through. This dish also freezes well—wrap tightly and freeze for up to 2 months.