Here's the relevant paragraph:
1(1)Section 85(1), so far as relating to sex, does not apply in relation to a single-sex school.
(2)A single-sex school is a school which—
(a)admits pupils of one sex only, or
(b)on the basis of the assumption in sub-paragraph (3), would be taken to admit pupils of one sex only.
(3)That assumption is that pupils of the opposite sex are to be disregarded if—
(a)their admission to the school is exceptional, or
(b)their numbers are comparatively small and their admission is confined to particular courses or classes.
(4)In the case of a school which is a single-sex school by virtue of sub-paragraph (3)(b), section 85(2)(a) to (d), so far as relating to sex, does not prohibit confining pupils of the same sex to particular courses or classes.
And here are the explanatory notes:
This paragraph allows a single-sex school to refuse to admit pupils of the opposite sex. A school is defined as single-sex if it admits pupils of one sex only. This is so even if it admits a small number of pupils of the opposite sex on an exceptional basis or in relation to particular courses or classes only. Limiting those pupils to particular courses or classes is not discrimination. However, other forms of sex discrimination by the school against its opposite-sex pupils would still be unlawful.
Examples
A school which admits only boys is not discriminating unlawfully against girls.
If the daughters of certain members of staff at a boys’ school are allowed to attend, it is still regarded as a single-sex school.
A boys’ school which admits some girls to the Sixth Form, or which lets girls attend for a particular GCSE course not offered at their own school is still regarded as a single-sex school.
A boys’ school which admits girls to A-level science classes is not discriminating unlawfully if it refuses to admit them to A-level media studies or maths classes.
A boys’ school which admits girls to the Sixth Form but refuses to let them use the same cafeteria or go on the same visits as other Sixth Form pupils would be discriminating unlawfully against them.