In a saucepan, melt butter. Add flour, salt and pepper to make a roux. Add milk and stir until thick and bubbly. Add cheese (reserving some for topping), stir until melted.
Arrange half the potatoes in a 1-1/2 quart casserole dish; cover with half the onion and half the sauce. Repeat layers. Cover and bake about 1 hour. Uncover, top with reserved cheese, and bake 30 minutes longer.