3 tablespoons butter, plus additional for greasing the baking dish
1/4 cup diced onion
3 tablespoons all-purpose flour
2 cups whole milk
Salt and pepper
1 pound potatoes, thinly sliced into rounds
2 cups shredded Swiss cheese, divided
1/2 pound thinly sliced deli ham
Preheat the oven to 350 degrees F and grease a 13-by-9-inch baking dish with butter.
In a large skillet, melt the butter over medium-high heat. Add the onions and cook, stirring, until they soften, about 4 minutes.
Sprinkle the flour over the onions and continue to cook, stirring for 1 to 2 minutes, until the flour just begins to color. Slowly add the milk and cook, stirring constantly, until the sauce thickens.
Remove from the heat and stir in one-third of the shredded cheese. Stir in salt and pepper to taste.
Arrange half of the potato slices in the baking dish. Layer half of the ham slices over the top, sprinkle on half of the remaining shredded cheese and pour over half of the sauce.
Arrange the remaining potatoes in another layer, and top with the remaining ham, the remaining sauce and the remaining cheese.
Cover with aluminum foil and bake for 45 minutes.
Remove the foil and continue to bake until the top is browned and the sauce is bubbling, 15 to 20 minutes more.