Heat the olive oil in a medium saucepan over medium heat.
Add the diced onion and cook for 3 to 5 minutes, stirring occasionally, until translucent.
Add the chopped garlic and cook for another minute until fragrant, being careful not to let it brown.
Stir in the chopped tomatoes, dried basil, dried oregano, and optional chili flakes.
Season with salt and pepper to your liking.
Bring the sauce to a gentle simmer, then reduce the heat to medium-low.
Cover the saucepan and let it cook for 15 to 20 minutes for the flavors to meld together.