Preheat the oven to 375°F (190°C). Boil salted water in a large pot and cook the ziti until al dente; drain and set aside.
In a large skillet over medium heat, heat olive oil and sauté the chopped onion and minced garlic until fragrant.
Add the ground beef or Italian sausage and cook until browned; drain excess fat.
Stir in the marinara sauce and Italian seasoning, simmering for a few minutes.
In a separate bowl, combine ricotta cheese, egg, half of the mozzarella, salt, and pepper; mix until smooth.
In a greased baking dish, layer half of the cooked ziti, spread the ricotta mixture, and add half the sauce; repeat layers.
Top with remaining mozzarella and Parmesan cheese.
Cover with foil and bake for 20 minutes, then remove foil and bake an additional 10–15 minutes until cheese is melted and bubbly.
Let rest for a few minutes before serving; garnish with fresh basil or parsley if desired.