Preheat the oven to 400 degrees . Line a 12-cup muffin tin with paper baking liners. In a large bowl, whisk together the flour, sugar, baking soda, salt and pepper to combine.
In a large nonstick skillet, cook the bacon over medium heat, stirring occasionally, until crisp but not dry. Using a slotted spoon, transfer the bacon to a small bowl. Discard the bacon fat. Add the butter to the skillet and melt over medium heat. Add the onion and cook, stirring frequently, until softened, about 5 minutes. Stir in the chopped bacon and remove from the heat.
Stir the corn into the dry ingredients. Make a well in the center and add the buttermilk, egg and bacon mixture. Fold the ingredients together until just combined. Divide the batter equally among the baking liners. Bake, rotating the pans halfway through, until the tops are golden and a toothpick inserted in the center comes out clean, about 20 minutes. Let the muffins cool on a rack.