Meanwhile, in a large skillet over medium heat, heat oil. Add onionsand cook until soft and translucent, about 5 minutes. Stir in garlic and cook until fragrant, 1 minute more. Add ground beef, season with salt, pepper, and Italian seasoning, and cook until no longer pink, about 8 minutes. Drain fat in a bowl lined with paper towels and return to pan. Pour in crushed tomatoes and basil and simmer until slightly reduced, about 10 minutes. Season with more salt and pepper to taste.
Toss with spaghetti, then transfer to baking dish and top with mozzarellaand Parmesan. Bake until cheese is melted and pasta is warmed through, about 20 minutes.