01 - Preheat oven to 375°F and lightly grease a 9x13-inch baking dish.
02 - Bring a large pot of salted water to a boil. Cook ziti until al dente according to package instructions. Drain and set aside.
03 - Heat olive oil in a large skillet over medium heat. Add chopped onion and sauté for 3 to 4 minutes until softened. Add garlic and cook for 1 minute until fragrant.
04 - Add ground beef to skillet and cook, breaking up meat with a spoon, until browned and cooked through, about 5 to 6 minutes. Drain excess fat if necessary.
05 - Stir in marinara sauce, Italian seasoning, crushed red pepper flakes if using, salt, and pepper. Simmer for 5 minutes off heat to blend flavors.
06 - In a medium bowl, combine ricotta cheese, 1 cup mozzarella, ¼ cup Parmesan, and egg until evenly mixed.
07 - In the prepared baking dish, layer half of the cooked ziti, followed by half the meat sauce, then half the ricotta mixture. Repeat layers with remaining pasta, sauce, and cheese mixture.
08 - Sprinkle remaining 1 cup mozzarella and ¼ cup Parmesan evenly over the top.
09 - Cover with foil and bake for 25 minutes at 375°F.
10 - Remove foil and bake an additional 10 to 15 minutes until cheese is melted, bubbly, and lightly golden.
11 - Let the dish rest for 10 minutes before serving. Garnish with fresh basil or parsley if desired.