Preheat the oven to 425°. Oil an 8-by-12-inch baking dish. In a medium skillet, heat the olive oil. Add the onion and thyme and cook over moderate heat, stirring occasionally, until the onion is softened, about 7 minutes. Scrape the onion into the prepared baking dish and spread evenly over the bottom.
Arrange the tomato slices over the onion in overlapping rows. Season with salt and pepper and drizzle with the balsamic vinegar. Dot the tomatoes with the butter and sprinkle the Parmigiano-Reggiano on top. Bake on the upper rack for about 15 minutes, until the cheese starts to brown and the gratin is bubbling. Let rest for about 5 minutes before serving.
The assembled gratin can be refrigerated overnight. Bring to room temperature before baking.