Preheat oven to 400°F, cut the top off the garlic head, drizzle with olive oil, wrap in foil and roast for 35 minutes until soft and golden.
While garlic roasts, heat 1 tablespoon butter and olive oil in a large skillet and cook sliced onions over medium-low heat for 25-30 minutes, stirring occasionally, until deeply caramelized.
Cook macaroni according to package directions until al dente, drain and set aside.
Squeeze the roasted garlic cloves from their skins and mash into a paste.
In a large pot, melt 4 tablespoons butter over medium heat, whisk in flour and cook for 2 minutes.
Gradually whisk in milk and bring to a simmer, stirring until thickened, about 6 minutes.
Remove from heat and stir in roasted garlic paste, cheddar, and Gruyere until melted, then add salt, pepper, and nutmeg.
Fold in cooked macaroni and caramelized onions, transfer to a greased 9x13 baking dish, top with panko breadcrumbs, and bake at 350°F for 20 minutes until golden and bubbly.