Please don't use physical punishment on a dog - they don't really rationalize the way humans do, and won't understand why you're angry.
Just keep him gated downstairs in the kitchen or living room so he can't go upstairs. crate train him as well so he can settle down in a confined space.
Just keep him gated downstairs in the kitchen or living room so he can't go upstairs. crate train him as well so he can settle down in a confined space.