Where I have to write my hook
"To implement a hook, add a function to the module's main .php file created earlier with civix generate:module" - the developer guide.

However, if you've created your own page class, you may not need to use a hook at all, since you have complete control of the code.

If I haven't answered your question, please update your question with a bit more detail about what you're trying to do.