Make the filling first: In a medium bowl with a hand mixer (or stand mixer with paddle), beat peanut butter and softened butter until completely smooth and slightly aerated, 1–2 minutes. Add powdered sugar in 3 additions, mixing on low to combine. Beat in vanilla and a pinch of salt, then add cream 1 teaspoon at a time until the frosting is spreadable but holds peaks. Scrape into a piping bag or bowl, cover, and chill 20 minutes to firm.
For the cookies, whisk flour, cocoa, baking soda, salt, and espresso powder in a large bowl to evenly distribute the leavener and cocoa.
In a separate bowl, cream the softened butter and granulated sugar on medium-high until light and fluffy, 2–3 minutes. Beat in the egg until just combined, then mix in vanilla.
Add the dry ingredients to the butter mixture and mix on low until a soft dough forms with no dry streaks. If the dough feels sticky, cover and refrigerate for 15 minutes to make scooping easier.
Preheat the oven to 325°F (165°C). Line two baking sheets with parchment paper.
Scoop level 1-tablespoon portions of dough, roll into balls, and arrange 2 inches apart. Gently press each ball with the flat bottom of a measuring cup to about 1/2-inch thick to encourage even baking.
Bake 11–13 minutes, rotating pans halfway through, until edges are set and tops look matte. Let cookies cool on the sheets for 8 minutes, then transfer to a rack to cool completely.
Assemble: Pair cookies by size. Pipe or spread 1 to 1 1/2 tablespoons of chilled peanut butter filling onto the bottom of one cookie. Cap with a second cookie and twist gently to distribute the filling to the edges. Sprinkle a few flakes of sea salt on top if using.
Let the sandwiches rest 15 minutes at room temperature so the filling sets before serving.