Heat butter and olive oil in a large skillet over medium-low heat. Add thinly sliced onions, sprinkle with salt and brown sugar. Cook slowly, stirring occasionally, for about 25-30 minutes until the onions turn deep golden brown.
In the last minute of cooking, add balsamic vinegar to the onions and stir to incorporate. Remove from heat and allow to cool.
Preheat oven to 375°F (190°C). Line a 12-cup muffin tin with paper liners or generously grease with butter or cooking spray.
In a large mixing bowl, whisk together flour, baking powder, salt, pepper, and thyme leaves until well combined.
Fold in 1 cup of grated Gruyère cheese and diced apples to the dry mixture, ensuring they're well coated with flour.
In a separate bowl, whisk together eggs, milk, olive oil, and honey until smooth and well combined.
Pour the wet ingredients into the dry ingredients and stir just until combined – about 10-12 strokes. The batter should look slightly lumpy.
Gently fold in the cooled caramelized onions, distributing them evenly throughout the batter.
Divide the batter evenly among the prepared muffin cups, filling each about ¾ full.
Sprinkle the tops with the remaining ¼ cup grated Gruyère, chopped walnuts (if using), and fresh thyme leaves.
Bake for 22-25 minutes, or until the tops are golden brown and a toothpick inserted into the center comes out clean.
Allow the muffins to cool in the pan for 5 minutes before transferring to a wire rack to cool completely.