In a large skillet, heat the olive oil over medium heat. Add the diced onion and sauté for about 3-4 minutes until softened. Stir in the minced garlic and cook for an additional minute until fragrant.
Add the ground beef or sausage to the skillet. Cook until browned, breaking it apart with a spoon, about 5-7 minutes. Drain any excess fat if necessary.
Stir in the dried oregano, dried basil, red pepper flakes (if using), crushed tomatoes, salt, and pepper. Bring the mixture to a simmer and let it cook for about 10 minutes, allowing the flavors to meld.
Add the gnocchi to the skillet, stirring gently to combine. Cover and cook for an additional 5-7 minutes, or until the gnocchi are cooked through and tender.
Remove the skillet from heat and dollop the ricotta cheese over the top. Sprinkle the shredded mozzarella and grated Parmesan evenly over the ricotta.
Cover the skillet again and let it sit for about 5 minutes, allowing the cheese to melt.
Garnish with fresh basil leaves if desired before serving.