If you catch it happening
A calm, gentle interruption and an immediate, unhurried trip to the right spot is the most useful response — followed by real praise if they finish there.
If you find it after the fact
Clean it up without comment. Dogs do not reliably connect a delayed reaction to something that already happened, so scolding after the fact mostly adds stress without teaching anything.
The cleanup itself matters
An enzyme cleaner breaks down the compounds a regular household cleaner leaves behind, which reduces the chance your dog is drawn back to the same spot by scent alone.
What to avoid
Keep the response gentle.
Avoid rubbing your dog's nose in an accident. It does not teach the connection you are hoping for, and it can damage trust.
Safety boundary
When to get more help.
Frequent accidents in the same spot despite thorough cleaning may mean the odor is not fully gone, or that the schedule around that area needs adjusting.