Preheat your oven to 375°F (190°C). Grease a 9x9-inch baking dish.
In a medium saucepan, melt the butter over medium heat. Whisk in the flour and cook for 1 minute.
Slowly pour in the milk, whisking continuously to prevent lumps. Cook until the mixture thickens, about 3-4 minutes.
Remove from heat and stir in the cheddar cheese, Parmesan cheese, garlic powder, and paprika. Season with salt and pepper.
Layer half of the potato slices in the prepared baking dish. Top with half of the onion slices and half of the cheese sauce. Repeat with the remaining potatoes, onions, and sauce.
Cover the dish with aluminum foil and bake for 50 minutes. Remove the foil and bake an additional 15-20 minutes, until the potatoes are tender and the top is golden brown.
Let rest for 5 minutes before serving. Garnish with fresh herbs if desired.