The revised Good Medical Practice (GMC) guide follows a consultation period and covers areas such as relationships with patients, and integrity.
The main core standards cover seven areas: good clinical care, maintaining good medical practice, teaching and training, appraising and assessing, relationships with patients, working with colleagues, probity and health. Supplementary guidance in the GMC guide also offers advice on "maintaining boundaries" with patients.
That guidance says doctors "must not pursue a sexual relationship with a former patient" if the patient was vulnerable, such as suffering mental health problems or showing a lack of maturity, at the time of the professional relationship.
"Pursuing a sexual relationship with a former patient may be inappropriate, regardless of the length of time elapsed since the therapeutic relationship ended," it adds.
"This is because it may be difficult to be certain that the professional relationship is not being abused.
"If circumstances arise where a sexual relationship may start, then a doctor should take account of when the professional relationship ended and how long it lasted, the nature of the previous professional relationship, whether the patient was particularly vulnerable at the time of the professional relationship, and whether they are still vulnerable."
Doctors should also consider whether they are caring for other members of the patient's family.
The GMC, which is the regulatory body for the UK's 240,000 registered doctors, also wants to increase awareness of what patients should expect from their doctor.
Patients will also be encouraged by doctors to look after their own health more.