6 medium leeks, white and tender green parts only, sliced 1/4 inch thick
3 garlic cloves, minced
6 tablespoons unsalted butter
2/3 cup all-purpose flour
1 quart whole milk
1/2 cup shredded Gruyère cheese
1/2 cup freshly grated Parmigiano-Reggiano cheese
1/4 teaspoon freshly grated nutmeg
Freshly ground pepper
In a large pot of boiling water, blanch the chard in batches until wilted, about 1 minute. Drain the chard, squeeze dry and chop it.
Heat the oil in the pot. Add the leeks and a pinch of salt. Cover and cook over moderately low heat, stirring, until tender, 7 minutes. Uncover, add the garlic and cook, stirring, until fragrant, 2 minutes. Add the chard, season with salt and remove from the heat.
Preheat the oven to 425°. Butter a 10-by-15-inch baking dish. In a large saucepan, melt the butter. Stir in the flour over moderate heat to form a paste. Gradually whisk in one-third of the milk and cook, whisking, until the mixture starts to thicken. Repeat two more times with the remaining milk. Bring the sauce to a boil, whisking constantly. Reduce the heat to low and cook, whisking often, until thickened and no floury taste remains, 15 minutes. Whisk in the cheeses and the nutmeg; season with salt and pepper. Mix the sauce into the leeks and chard. Season with salt and pepper.
Transfer the mixture to the prepared baking dish. Bake in the upper third of the oven for about 25 minutes, until bubbling and golden brown on top. Let rest for at least 10 minutes before serving.
The unbaked gratin can be refrigerated overnight. Bring to room temperature before baking.