Bring a large pot of salted water to a boil and cook spaghetti according to package instructions until al dente. Drain and set aside.
Heat olive oil in a large skillet or saucepan over medium heat. Add chopped onions and sauté until translucent, about 5 minutes.
Add minced garlic and cook for 1 minute until fragrant.
Stir in crushed tomatoes, oregano, red pepper flakes (if using), salt, and black pepper. Add sugar if desired to balance acidity.
Simmer the sauce over medium-low heat for 15–20 minutes, stirring occasionally, until slightly thickened and flavors melded.
Taste and adjust seasoning with salt and pepper.
Add the cooked spaghetti to the sauce and toss to coat evenly.
Remove from heat and stir in fresh basil leaves.
Serve immediately, garnished with additional basil and grated Parmesan if desired.