The amendment to the Education and Inspections Bill was opposed by ministers and overwhelmingly defeated in the House of Lords, despite the backing of a report from one of the Government's favourite think-tanks and a coalition of health charities.
An Institute for Public Policy research report reminded MPs that British teenagers are the most sexually active in Europe and have the highest teenage pregnancy rate. The institute called for statutory PSHE lessons and for children to be taught about contraception in the final year of primary.
British pupils are the third least likely in Europe to wear a condom during sex.
The think-tank believes condoms should be free or sold at low cost to young people in schools, colleges and sports centres.
The only compulsory sex education comes in the science curriculum which says 11 to 14 year-olds must learn about the human reproductive system and adolescent physical changes.
Schools can teach it through PSHE, but Paul Ennals, the children's charity NCB's chief executive, said: "Because it is not a statutory subject, it can be difficult for some schools to give it priority."
Lord Adonis, schools minister, told the House of Lords that making it compulsory would lead to "very prescriptive requirements" on schools. But, he said, PSHE teaching was being strengthened.
The Bill also includes powers to set up the controversial semi-independent trust schools, quicker interventions in failing schools and a clear legal right for school staff to discipline pupils.
It will also force schools to "act in accordance" with rather than "having regard" to the admissions code.
The latest version of the code, to be introduced in February, prevents schools that partially select by ability from giving priority to the siblings of existing pupils. The code argues the practice can allow disproportionately high numbers of children living close to the school being denied a place, and those from poorer families being discriminated against.
Parents at the partially selective Dame Alice Owen school, Potters Bar, Hertfordshire are campaigning against the change, arguing that many chose the school for older children assuming their siblings could follow.