that will happen automatically if you have the correct listeners in place. if you register the correct WorkItemHandler it will notify the process engine as soon as you finish the task.
Look at the GenericHTWorkItemHandler and all the derived classes.
Cheers