1. Position rack in top third of oven and preheat to 425°F. Place bread, cut side up, on a rimmed baking sheet and bake 5 minutes. Remove from oven and rub cut sides with garlic.
2. Spread tomato sauce on cut sides of bread. Top with mozzarella, pepperoni, and red-pepper flakes, if using.
3. Bake until cheese is melted and golden brown, about 10 minutes. Top with basil.