The grammar pattern ~ところに / ~ところへ expresses that something happens right at the moment when a certain situation is taking place. It highlights the timing of an unexpected event – often an interruption, arrival, or coincidence – that occurs precisely when someone is in the middle of doing something, about to do something, or has just finished doing something.
The particle に or へ can be used somewhat interchangeably, though へ tends to emphasize movement or arrival toward a place/person.
The verb before ところ determines the timing:
Verb[ている] + ところに – Right in the middle of doing something (interruption while in progress)
Verb[た] + ところに – Right after finishing something
Verb[dictionary form] + ところに – Right when about to do something
The second event is typically unexpected or coincidental – something that happens to occur at that particular moment. The speaker often did not anticipate it. Because of this, ~ところに frequently appears with verbs describing someone arriving, contacting, or interrupting.
While ~ところに / ~ところへ focuses on the timing of an event happening to the subject, the related pattern ~ところを is used when someone is caught or observed in the middle of doing something. They are not interchangeable.