Heat oven to 400°F. Slice off the top quarter of the head of garlic, place on a piece of foil and drizzle with 1 tablespoon of the olive oil. Season with salt and pepper and wrap foil around to cover completely. Roast until the cloves are very soft, about 45 minutes. Remove from oven, let cool, then pop the cloves out of the skin.
Heat remaining oil in a large soup pot over medium heat. Add onions and season with salt and pepper. Cook, stirring occasionally, until onions are soft and beginning to brown. Add potatoes and stir to coat in oil. Season again and add tomatoes, roasted garlic, and stock (start with four cups and add more later if it seems too thick).
Bring to a boil, then reduce heat and simmer until potatoes are tender. Add chard and cook for another 15 minutes or so until chard is really tender. Blend soup as smooth as you like it, add more stock if it seems thick and season with more salt and pepper if necessary. Serve with a dollop of pesto if you have it on hand.