Preheat the oven to 350 degrees. In a 10-inch skillet, heat 2 tablespoons of oil over medium heat. Add leeks and 2 tablespoons water; season with salt and pepper. Cook, stirring occasionally, until they begin to brown, about 10 minutes. Add sherry and sage and cook until liquid is reduced to a glaze, about 3 minutes; set aside.
In a 2-quart shallow baking dish, arrange squash in overlapping layers; season with salt and pepper. Spread leeks evenly over the squash.
Arrange apples in an overlapping layer over the leeks. Brush apples with remaining tablespoon oil. Cover tightly with aluminum foil. Bake 45 minutes.
Uncover and sprinkle cheese over the top. Raise the oven temperature to 450 degrees and bake 10 minutes, or until the cheese has melted and is golden brown. The tip of a paring knife should easily pierce the gratin. Let cool 10 minutes before serving. Garnish with sage leaves.