Whenever needed, but certainly before landing - which is why you often see the last of the water being dumped on final.
The idea is to match the amount of water to the day. The stronger the day the more water. A typical competition tactic is to load more water than you think will be needed and, after testing the thermals, dump some before the start. This is because it is very difficult to add water while in flight. :)
Also, as the day dies towards the end, it is common to dump some more.