Preheat oven to 375°F (190°C).
Heat olive oil in a skillet over medium heat. Add chopped onion and sauté until soft and translucent, about 5 minutes.
Add diced Spam to the skillet and cook until browned and slightly crispy, about 7–8 minutes.
Stir in smoked paprika and black pepper, then remove from heat.
In a baking dish, combine the baked beans with the cooked Spam and onions, mixing gently.
Top with grated cheddar cheese if using.
Bake uncovered for 25 minutes, until bubbly and cheese is melted and golden.
Let cool slightly before serving. Enjoy warm as a hearty side or main dish.