Once a Task is assigned, it can be locked so that it doesn’t get transferred to a different route when reoptimizing. It will still be able to shift around within the route.
To do this, right-click the Task you wish to lock and select Lock.
At the moment, locking a Task does not mean it will stay in the Route - it means it will only be associated with the Driver whose Route the Task is a part of. However, if there are other, better solutions where other Tasks fit into that Route, the Locked Task might get pushed out of the Route in favor of fitting another Task. The only way to prevent Tasks from ever falling out of the Route is by giving them a higher priority (which significantly increases the likelihood of the Task being kept in the route) or locking the Route (which completely prevents Tasks from moving within the route and being removed from the route)