Add bacon to a large skillet over medium heat. Sauté the bacon until the fat has rendered and the bacon is crispy, about 10 to 12 minutes. Use a slotted spoon to remove the bacon to a paper towel to drain. Remove all but 2 tablespoons of the fat from the pan and return the pan to medium heat.
Add the olive oil to the pan with the bacon fat and heat through. Add the onions and toss quickly to remove the moisture from the onions. Sauté, stirring occasionally, until the onions are soft and start to brown.
Sprinkle the salt and sugar over the onions (to help them caramelize) and reduce the heat to medium-low and cook, stirring occasionally, until the onions are light brown and begin to caramelize, about 20 minutes.
Continue to cook until the onions are uniformly brown and caramelized, about an additional 10 minutes. Return the bacon to the pan and add the beef stock. Let simmer until the beef stock has evaporated and the onions have a jam-like texture.
Remove from the pan and set aside or cover and refrigerate until ready to use.