Preheat oven to 375 degrees F. Grease or spray a 9x13 baking pan. Layer 1/2 of the sliced potatoes, 1/2 of the sliced onion, 1/2 of the garlic, 1/2 of the rosemary and sprinkle with salt and pepper. Repeat layer one more time.
In a medium saucepan melt the butter over medium to medium-low heat. Stir in the flour and cook for 1 minute. Whisk in the milk and cook stirring occasionally until it thickens slightly.
Pour milk mixture over the potatoes and bake uncovered for 45-55 minutes or until potatoes are tender. Let stand 5-10 minutes to allow the sauce to thicken.