From the BBC website
Lord Sugar decides the winner on the basis of the final task, the boardroom, and their overall performance throughout the series.
He makes his decision on the day of the final boardroom meeting. As there is a gap between the shoot and transmission (to leave time for editing), measures are taken to ensure that the outcome is kept a secret for viewers prior to transmission.
Two endings are filmed in order to ensure that the winner is not revealed in advance. Lord Sugar does not tell the production team and the finalists about the identity of his new business partner until the day before the transmission of the final programme.