Rinse the fennel and finely chop the leaves. Slice the fennel bulbs lengthwise, season with salt and roll in flour. Heat the olive oil in a large frying pan and saute the fennel slices for about 5 minutes, until golden brown on both sides.
Slice the mozzarella and grate the gruyere. Boil the tomatoes over high heat for about 5 minutes and crush finely. Rinse the herbs and finely chop the leaves. Grease a baking dish and spread half of the fennel slices on the bottom.
Spread half of the mozzarella on top and season with salt and pepper. Add the chopped fennel leaves and herbs. Sprinkle with 1/3 of the grated cheese. Top with the remaining fennel slices, remaining mozzarella and 1/3 of the grated cheese.
Season the tomato sauce and pour over the gratin. Sprinkle with the remaining cheese. Bake for about 25 minutes at 220°C (approximately 425°F). Remove from the oven and serve immediately.