Combine garlic, rosemary and cream in a small saucepan over medium heat. Cook, stirring and watching carefully to make sure the cream doesn’t boil over, until the rosemary has slightly wilted and lost some of its color, 4 to 6 minutes. Turn off the heat and season with salt and pepper. Pluck out and discard the rosemary sprigs.
Heat the oven to 400 degrees. Cut the cauliflower in half and break apart the florets, separating them from the thick stems; thinly slice the stems. (It’s OK if some of the florets are very small and some are big.) Cut in half any pieces that are larger than 3 inches. Quarter the shallots through their roots and remove their skins.
Arrange the cauliflower and shallots in a 2-quart baking dish. Pour the garlicky cream over top. (Not all of the cauliflower will be buried under the cream, but that’s OK.) Scatter the cheese on top and cover tightly with foil.
Bake until the cauliflower and shallots are tender and the edges are starting to brown, 25 to 30 minutes. Uncover and continue to bake until the top is deep golden brown, another 25 to 30 minutes. Let cool slightly before serving.
