01 - Preheat oven to 375°F and lightly grease a 9x13 inch baking dish.
02 - Boil ziti in a large pot of salted water until just under al dente; drain thoroughly and set aside.
03 - Heat olive oil in a large skillet over medium heat. Sauté the chopped onion until softened, about 3 minutes, then add minced garlic and cook for an additional minute.
04 - Add ground beef to the skillet, breaking it up with a spoon, and cook until thoroughly browned. Drain any excess fat.
05 - Stir in tomato paste, crushed tomatoes, oregano, basil, red pepper flakes (if using), salt, and black pepper. Bring to a simmer and cook for 10 minutes, stirring occasionally.
06 - In a large mixing bowl, gently combine the drained pasta, the prepared meat sauce, ricotta cheese, and half of the shredded mozzarella.
07 - Spread half of the pasta mixture evenly into the prepared baking dish. Sprinkle with half of the Parmesan cheese. Layer the remaining pasta mixture on top, then finish with the remaining mozzarella and Parmesan.
08 - Cover the baking dish loosely with aluminum foil and bake for 20 minutes.
09 - Remove the foil and continue baking for an additional 10–15 minutes, or until the cheese is golden and bubbling.
10 - Allow the casserole to rest for 5 minutes before serving. Garnish with chopped fresh basil or parsley, if desired.