Heat the oven to 350°F (175°C) and line two baking sheets with parchment paper. Whisk 2 cups of flour, 1/2 cup of Dutch-process cocoa, 1 1/2 teaspoons of baking soda and 1/2 teaspoon of salt in a medium bowl until evenly mixed.
Beat 1/2 cup of softened butter with 1/2 cup of granulated sugar and 1/2 cup of brown sugar on medium speed until light and fluffy, about 3 minutes. Beat in 1 large egg, 1 teaspoon of vanilla and 1/2 teaspoon of peppermint extract. Add the dry ingredients in two parts, alternating with 1 cup of buttermilk, mixing only until the flour disappears.
Use a 2-tablespoon cookie scoop to drop even mounds of batter onto the prepared sheets, about 2 inches apart. Bake for 10 to 12 minutes, until the tops look set and spring back lightly. Cool on the sheet for 5 minutes, then move to a wire rack and cool completely, about 30 minutes.
Beat 1/2 cup of softened butter until creamy, about 1 minute. Add 2 cups of powdered sugar in two parts, beating on low, then add 1 tablespoon of milk, 1 teaspoon of peppermint extract and a pinch of salt. Beat on medium-high for 2 minutes until smooth and fluffy.
Crush 4 candy canes into small pieces and spread them on a plate. Pair the cooled cookies into matching sizes. Spread or pipe about 2 tablespoons of filling onto one cookie of each pair, press the second cookie on top gently until the filling reaches the edge, then roll the exposed filling edge in the crushed candy canes.
Chill the finished whoopie pies for 15 minutes so the filling firms up. Garnish with the 2 whole candy canes, dust with powdered sugar if you like, and serve at room temperature.