This study investigates the ability to use foreknowledge in preparation of cognitive processes in young and older participants and in PD patients. Additionally, we test the hypothesis that age-associated cognitive deficits in task switching reflect a dopaminergic dysfunction that accompanies healthy aging. To this end, we use a task-switching paradigm that (i) is known to be highly sensitive for dopaminergic dysfunction in the frontostriatal loops and (ii) can be applied with predictable and unpredictable switch and non-switch trials to assess the effect of task foreknowledge. Our results show that young participants benefit from foreknowledge and are thus able to prepare for predictable cognitive processes. Older participants have lost their ability to benefit from foreknowledge, which seems to be an effect of healthy aging. In predictable trials, the performance of PD patients did not differ from that of controls. Thus, PD patients do not show an additional deficit in the preparation of predictable cognitive switches. However, PD patients are specifically impaired in unpredictable trials compared to controls. We suggest that this result can be explained by the uncertainty about the next task in the unpredictable condition which prevents an automatic process and demands more attention. Furthermore, our results of older participants do not resemble the deficits seen in PD patients in task-switching behavior. This argues for different mechanisms that underlie the changes in task-switching behavior in healthy aging and PD.