Preheat your oven to 350°F (175°C).
Cook the penne pasta according to package instructions until al dente. Drain and set aside.
In a large skillet over medium heat, brown the ground beef with the chopped onion and minced garlic until the meat is cooked through. Drain excess fat.
Stir in the diced tomatoes, tomato sauce, Italian seasoning, salt, and black pepper. Bring to a simmer for about 5 minutes.
Add the cooked penne pasta and sliced pepperoni to the skillet, mixing well to combine all ingredients.
Transfer the mixture to a greased 9x13-inch baking dish.
Sprinkle the shredded mozzarella and grated Parmesan cheese evenly over the top.
Bake in the preheated oven for 25-30 minutes, or until the cheese is melted and bubbly.
Remove from the oven and let it cool for a few minutes before serving. Garnish with fresh basil if desired.