Cook the Spaghetti: Bring a large pot of salted water to a boil. Add the spaghetti and cook according to package instructions until al dente, about 8-10 minutes. Drain and set aside, reserving 1/2 cup of pasta water.
Prepare the Meat Sauce: While the pasta cooks, heat olive oil in a large skillet over medium heat. Add the chopped onion and sauté for 3-4 minutes until softened and translucent. Add the garlic and cook for another 1 minute until fragrant.
Brown the Meat: Add the ground beef to the skillet, breaking it up with a wooden spoon. Cook for 5-7 minutes until browned and cooked through. Drain excess fat if needed.
Build the Sauce: Stir in the tomato paste and cook for 1 minute. Add the crushed tomatoes, oregano, basil, red pepper flakes (if using), sugar, salt, and black pepper. Stir well to combine. Reduce heat to low and let the sauce simmer for 15-20 minutes, stirring occasionally, until it thickens slightly. If the sauce gets too thick, add a splash of reserved pasta water to adjust the consistency.
Combine and Serve: Add the cooked spaghetti to the sauce, tossing to coat evenly. If the sauce is too thick, add more reserved pasta water as needed. Divide the spaghetti among plates, garnish with fresh basil leaves, and sprinkle with grated Parmesan cheese.