Preheat oven to 350°F (180°C). Line a cupcake pan with 6 liners, alternating them in the pan.
Whisk together flour, cocoa powder, baking powder, baking soda, and salt.
In a separate bowl, whisk together egg, sugar, vanilla, oil, and buttermilk. Add the dry ingredients and mix just until combined. Don’t overmix.
Divide batter between the 6 liners, filling each about ⅔ full. Bake for 15–20 minutes, or until a toothpick inserted into the center comes out clean. Cool in the pan for 5 minutes, then transfer to a wire rack to cool completely.
For the frosting: Beat the butter until light and fluffy, about 1 minute. On low speed, gradually mix in the powdered sugar. Beat for 1–2 minutes until fluffy.
Mix in the vanilla and heavy cream, then add the cocoa powder on low speed. Increase to medium-high and beat until light and fluffy, scraping down the bowl as needed.
Pipe onto cooled cupcakes and top with sprinkles if desired!
