Under the Equality Act 2010, where A engages in unwanted conduct related to a protected characteristic (www.practicallaw.com/7-503-3775) (or of a sexual nature) that has the purpose or effect of violating B's dignity or creating an intimidating, hostile, degrading, humiliating or offensive environment for B. Whether the conduct has that effect is judged subjectively from B's viewpoint, subject to a test of reasonableness.
For further information, see Practice note, Discrimination in employment: types of discrimination (EqA 2010): Harassment.