Preheat oven to 375°F and grease a 9x13-inch deep baking dish.
Heat olive oil in a large skillet over medium-high heat. Add diced onion and cook for 3 minutes until softened. Add minced garlic and cook for 1 minute.
Add ground beef and Italian sausage to the skillet, breaking apart with a spoon. Cook for 8-10 minutes until completely browned. Drain excess fat if needed.
Stir in Italian seasoning, salt, and black pepper. Mix well to combine.
Pour marinara sauce into the skillet and stir thoroughly. If using ricotta, fold it in gently. Simmer for 2-3 minutes.
Spread half of the meat and sauce mixture into the prepared baking dish. Sprinkle half of the pepperoni slices over this layer.
Top with half of the mozzarella cheese and half of the Parmesan cheese.
Add the remaining meat and sauce mixture on top. Layer the rest of the pepperoni slices and finish with remaining mozzarella and Parmesan cheeses.
Cover baking dish with aluminum foil and bake for 20 minutes. Remove foil and bake for another 10-15 minutes until cheese is melted, bubbly, and lightly golden.
Remove from oven and let rest for 5 minutes before serving.
Notes
Can be assembled ahead and refrigerated for up to 24 hours before baking. Freezer-friendly for up to 3 months.