If the participant fails the task set in user testing and clicks on the wrong sections, when is a good time to ask questions regarding why they clicked on those wrong sections? Is it better to ask before moving onto the next task so it is fresh in their minds or at the end of the testing when they have completed all the tasks?
For what it's worth, asking someone to explain their decision/behaviour is pretty much always going to get a post facto explanation invented on the spot. Asking for justification for their decisions too soon after they land in an unexpected place will also teach the participant when they're following your "right" path by not intervening, which could give them an artificial sense of confidence they wouldn't have without the benefit of you beside them.– Kit GroseMar 24, 2022 at 8:34
The answer to most questions when it comes to UX... It depends.
When to intervene depends on how stuck the participant is and if you are still observing interesting, active behavior during the test. You may learn something about what the expected behavior 'should' be based on what the user does.
It also depends on what fidelity the artifact is you're testing. If you're testing a static screen you may need to intervene to guide them a little more to the area of interest you're trying to gather learnings on. If you're testing a fully clickable prototype, let them browse naturally and discover what they need to.
If the participant finds their way through the 'task', let them continue and then come back to questioning after they've completed the test.
If the test has stalled totally, and the user is not actively trying to resolve the situation or friction they're encountering, it's time to intervene and ask 'WHY' they're stuck or 'WHAT' they're thinking.
Also, I need to add that the participant never fails. The user interface you're testing fails ;)