As a rule, I don't use "punishment," because I don't think it works and is detrimental to my relationship with the cat. IME, the best way to deal with cats going where you don't want them is a two pronged approach:
1.) Pick your battles. If your list of places the cat can't go and things the cat can't do is too long, the cat will be overwhelmed by it and will just ignire the "rules" and do whatever it feels like doing. I don't sweat the cat on the dining room table or the counters because it's just not worth fighting what will probably be a losing battle (as soon as you leave, the cat will just get up there anyhow, regardless of "punishment," because they know that they'll only get punished if you catch them). I just remove the cat with a snide comment and go about my business. However, I will not allow my cat on the woodstove, because it could badly injure her, so that's a battle I was willing to fight vigorously.
2.) Outthink the cat. Give them alternatives that are more appealing than the stuff you don't want them to do, and try to make it so it seems like it's their idea and not yours. I once managed to feed Assumpta a pill off my dinner plate which she scarfed down because she thought it was part of my dinner. Cat scratching posts and cat trees can be provided as a cat-attractive alternative to scratching the couch or climbing the bookshelf/counters. Cats want to scratch and climb, it's their instinct...so if there aren't sufficient outlets for it, they'll find their own places to scratch and climb, and you can't reasonably punish them for doing so. Add to that impersonal deterrents like double-sided tape on the furniture they like to scratch, and suddenly the scratching post seems a bit more attractive to them. It's not always easy to outthink a cat, and in cases where I utterly fail to manage it, I refer back to rule #1 and rethink whether it's a battle worth fighting.