Preheat Oven: Set your oven to 350°F (175°C).
Cook Spaghetti: Boil spaghetti in salted water until al dente. Drain and set aside.
Prepare Meat Sauce: In a skillet over medium heat, sauté diced onion until translucent. Add ground beef and cook until browned. Stir in minced garlic and Italian seasoning; cook for an additional minute. Pour in marinara sauce, season with salt and pepper, and let simmer for 5 minutes.
Mix Creamy Base: In a separate bowl, blend softened cream cheese (and sour cream if using) until smooth. Combine with cooked spaghetti, ensuring noodles are well-coated.
Assemble Casserole: In a greased 9x13-inch baking dish, layer half of the creamy spaghetti mixture. Top with the meat sauce, then add the remaining spaghetti. Sprinkle mozzarella and Parmesan cheeses evenly over the top.
Bake: Cover with aluminum foil and bake for 20 minutes. Remove foil and bake for an additional 10-15 minutes until cheese is bubbly and golden.
Rest and Serve: Allow the casserole to rest for 10 minutes before serving to let it set.