When should the maintenance phase of a project be planned

When should the maintenance phase of a project be planned?  Who (roles) needs to participate in the maintenance phase?