Preheat your oven to 350°F.
Cook the spaghetti according to package instructions until al dente, then drain.
Heat olive oil in a large skillet over medium heat; sauté onion until softened.
Add ground beef; cook until browned and crumbled. Drain excess grease.
Stir in minced garlic; cook briefly before adding marinara sauce, Italian seasoning, salt, and pepper. Simmer for 5–10 minutes.
Mix in ¼ cup Parmesan cheese with the sauce, then combine with cooked spaghetti.
Transfer mixture to a greased baking dish and top with mozzarella and remaining Parmesan.
Cover with foil and bake for 30 minutes; uncover and bake an additional 10–15 minutes until cheese is golden brown.
