Preheat an outdoor gas grill to high heat. Slice the tip off of each head of garlic to expose the cloves insides. Place each garlic head on a square sheet of aluminum foil. Drizzle exposed tips with 1 teaspoon olive oil. Wrap tightly with aluminum foil.
Place the garlic onto the grill and roast, turning occasionally, for 15 minutes. Roast the tomatoes on the grill until skins begin to blacken and burst, turning so that each side gets cooked.
Remove the garlic from the aluminum foil and allow the roasted tomatoes to cool until you are able to handle them. Squeeze the head of garlic to remove the cloves. Remove the peels from the tomatoes and cut out any inedible parts like stems.
In a large skillet over medium high heat, heat the olive oil and then saute the onion for about 5 minutes.
Transfer the onion to a slow cooker. Add in the peeled tomatoes, garlic cloves, salt, sugar, basil, and pepper. Use an immersion blender to puree everything together until fairly smooth. (If you don't have an immersion blender then put everything into a blender in batches to puree and then transfer the puree into the slow cooker).
Cook on low for 4-6 hours. Store in jars in the fridge if you will be using it within then next 1-2 weeks, or freeze it in quart sized freezer bags. Alternately, you may can it following proper canning procedures.