It's incorrect. Using the present perfect indicates that the action/ time is ongoing, (I have studied Spanish for two years)
by using the past simple 'when he came to the office' you have indicated that the action/time has finished and therefore you need to use the past simple, what did he see.
What did he see when he came to the office is correct,