Melt butter in a skillet over medium heat. Saut onion 6 minutes. Stir in spinach; remove from heat. In a bowl, whisk remaining ingredients through nutmeg.
Rub a 9-by-13-inch baking dish with garlic; discard.
Spread bread in dish; top with onion mixture and ham.
Add milk mixture. Press into bread. Cover with foil; chill 2 hours or overnight.
Preheat oven to 350F.
Bake, covered, until set, about 30 minutes. Uncover, scatter with rest of cheese; bake 10 minutes. Move rack to highest position; preheat broiler to high. Broil until golden, about 3 minutes.