Cut the top off the head of garlic to expose the cloves, drizzle with a little olive oil, and wrap it in aluminum foil. Bake in the preheated oven for 30-35 minutes, until the garlic is soft and caramelized.
While the garlic is roasting, bring a large pot of salted water to a boil. Add the spaghetti and cook according to package instructions until al dente. Reserve 1/2 cup of pasta water, then drain the noodles.
In a large skillet, heat 2 tablespoons of olive oil over medium heat. Squeeze the roasted garlic cloves out of their skins into the skillet and mash with a fork until smooth.
Add the heavy cream to the skillet and stir to combine, cooking for 2-3 minutes until warmed through.
Stir in the grated Parmesan cheese, allowing it to melt and create a creamy sauce. If the sauce is too thick, add reserved pasta water a little at a time until desired consistency is reached.
Add the chopped spinach and red pepper flakes (if using) to the sauce, cooking until the spinach is wilted.
Toss the drained pasta in the creamy garlic sauce until well coated. Season with salt and pepper to taste.
Serve the pasta in bowls, garnished with fresh basil leaves and an extra sprinkle of Parmesan cheese if desired.