Bring a large pot of salted water to a boil. Cook penne until just al dente, about 2 minutes less than package directions. Drain and return to the pot.
In a bowl, mix ricotta, 1 cup mozzarella, 1/4 cup Parmesan, the beaten egg, minced garlic, oregano, red pepper flakes (if using), salt, and pepper until smooth.
Preheat oven to 375°F (190°C). Spread 1 cup marinara on the bottom of a 9x13-inch baking dish. In the pasta pot, toss the drained penne with the remaining 2 cups marinara. Layer half the sauced penne into the dish, dollop all the ricotta mixture over it, then top with remaining penne.
Sprinkle the remaining 1 cup mozzarella and 1/4 cup Parmesan over the top. Mix panko breadcrumbs with melted butter and scatter evenly for a crisp crust.
Bake uncovered for 25-30 minutes, until the cheese is melted, the topping is golden brown, and the egg in the ricotta mixture is fully set (internal temperature at least 160°F/71°C). If the top browns too quickly, tent loosely with foil. Remove from oven and let rest 10 minutes.
Scatter torn basil over the baked penne and serve directly from the dish. Pair with a simple green salad and crusty bread.