The law doesn't generally require you to give a departing employee a reference unless stated otherwise in their contract, but it is good practice to ask whether they want one. You can use a Reference letter for this purpose. You should make sure that any reference given is true, accurate and a fair representation of the person. If the reference is misleading or unfair, an ex-employee could bring an action against you for libel, discrimination or defamation of character. For further information read Defamation.
The leaving employee may be able to gain access to a reference if they make a subject access request to their new employer. This is because employees are entitled to make a subject access request to view personal data that their employer holds about them. This may also include a reference given by past employers. Therefore when providing references employers should also be cautious about providing or processing information which is unnecessary or discriminatory such as sexual orientation, religion or age. For further information read Employee reference letters.