Preheat the oven to 400 degrees Fahrenheit (200 degrees Celsius). Butter a 1-quart casserole dish.
In the prepared casserole dish, layer 1/2 of the sliced potatoes on the bottom. Season with salt and pepper. Layer onion slices over the potatoes, then top with the remaining potatoes. Season again with salt and pepper.
Melt the butter in a medium-sized saucepan over medium heat. Gradually whisk in the flour and salt, and cook while whisking constantly until the raw flour flavor has cooked off, about 1 minute.
Gradually add milk, about 1/4 cup at a time, whisking well after each addition to incorporate; this gradual addition and whisking of milk will help avoid lumps in your sauce.
Cook, whisking constantly, until the mixture has thickened, which will take about 3 to 5 minutes. Stir in the cheese all at once; continue stirring until melted, which will take around 30 to 60 seconds.
Pour the cheese sauce over the potatoes, and cover the dish with aluminum foil.
Bake in the preheated oven until the potatoes are tender and the sauce is bubbly, which will take around 1 1/2 hours.
Enjoy your delicious creamy au gratin potatoes!
Notes
For optimal results, ensure that the potatoes are sliced into 1/4-inch (or even thinner) slices. A mandolin would come in handy if you have one available.