You should add some destination to where the funds will go after you complete the puzzle, correct.
So, even if the winner solves the scriptPubKey, how can then he/she divert the funds to another destination address?
They will just construct a transaction which includes an input that satisfies the conditions specified by the script. It would look like this:
Input:
- Previous Transaction Output: Puzzle Transaction Output
- ScriptSig: <puzzle_solution>
Output:
- Destination Address: XYZabc...