Add olive oil to medium nonstick frying pan and begin to heat over medium-high heat. Add onion and sauté, stirring often, until onion is nicely browned and caramelized (about 4 minutes). Drizzle pancake syrup (if desired) over the top and stir into the onions. Set aside to cool.
Toast bread slices if desired. Top two of the slices with the ham slices and spread the caramelized onions over the ham. Then spread a tablespoon of the cream cheese over the remaining two slices. Sprinkle shredded Gruyere cheese evenly over the top of the cream cheese.
Place all four slices in toaster oven or regular oven and broil, watching carefully, until the Gruyere cheese starts to bubble (about 3-4 minutes). Place the slices with the cheese over the slices with the ham and onions. Cut each sandwich on the diagonal and serve.