Preheat oven to 375°F (190°C) and grease a baking dish.
In a saucepan over medium heat, melt the butter and sauté the garlic until fragrant.
Stir in the flour and cook for 1 minute to form a roux.
Gradually whisk in the milk and cook until the sauce thickens.
Add the cheddar and Parmesan cheese, stirring until melted. Season with salt and pepper.
Layer half of the potato slices in the prepared dish, pour half the cheese sauce over them, and repeat with the remaining potatoes and sauce.
Cover with foil and bake for 45 minutes. Remove the foil and bake an additional 15 minutes or until the potatoes are tender and the top is golden brown.
Garnish with fresh parsley before serving, if desired.