In a gratin, savory ham and mild Gruyere cheese help to balance endive's slight bitterness.
Preheat oven to 400 degrees. Melt 2 tablespoons butter in a Dutch oven over medium heat. Add endives and 1/4 teaspoon salt. Cook, turning occasionally, until golden brown, about 6 minutes. Reduce heat to low; cover. Cook until soft and tender, about 30 minutes. Remove from heat; set aside, covered.
Butter a 6-by-10-inch baking dish; set aside. Place milk in a small saucepan over low heat. In another small pan, melt remaining 2 tablespoons butter over medium heat. Whisk in flour; cook, whisking constantly, for 1 minute. Slowly pour heated milk into mixture; whisk constantly, avoiding lumps. Add remaining 1/2 teaspoon salt and the nutmeg. Cook mixture; whisk slowly but constantly until thick and bubbling, about 1 minute. Remove from heat; set aside.
Wrap a piece of ham around each endive, and place in baking dish. Spoon sauce over endives. Sprinkle cheese over sauce. Bake until golden brown on top, 20 to 25 minutes. Serve immediately.