Where possible, it is worth parting on good terms with an employer so as not to run the risk of prejudicing any future reference they may be asked to provide about you.
There is no legal obligation to provide a reference except in a few sectors, such as financial services, but any reference that is provided must be true, accurate and fair. Your employer owes a duty both to you and any prospective employer.
Many employers have a policy of only providing a reference with very basic information (e.g. to confirm dates of employment and job title).
In practice, it may be sensible to raise the issue of your reference with your current employer directly before you leave, although this obviously depends on your personal circumstances. The text of references can sometimes be agreed as a term of any settlement and annexed to a settlement/compromise agreement, along with a promise that no oral reference will be given.