Preheat the oven to 350 degrees. Line a standard muffin tin with cupcake liners.
In a mixing bowl, whisk together the flour, baking soda, and salt.
In the bowl of an electric mixer, preferably fitted with the paddle attachment, cream together the butter and sugars on high speed until light and fluffy, about 3 minutes. Add the eggs, one at a time, beating well after each addition. Add the vanilla and beat well.
Turn the mixer on low and add half the flour mixture, then the sour cream, and finally the rest of the flour. Scrape the sides and bottom of the bowl well with a spatula to make sure everything is well combined. Stir in the bananas and walnuts. Divide the batter evenly among the prepared muffin tins and bake for 18-22 minutes or until a toothpick inserted into the center comes out clean. Let cool in the pan for 10 minutes, then transfer to a wire rack to finish cooling completely.
Frosting
In the bowl of an electric mixer, preferably fitted with the paddle attachment, beat all the ingredients together on medium speed until smooth and creamy.
Once the cupcakes are completely cooled, frost, and garnish with chopped walnuts, if desired.