Cameron made this statement on Tuesday, saying the group posed an existential threat to the West, but added that teaming up with Syrian President Bashar al-Assad to fight the organisation was "absolutely the wrong approach."
"There are people in Iraq and Syria who are plotting to carry out terrible acts in Britain and elsewhere and as long as Islamic State exists in those two countries we are at threat," he said.
Cameron was speaking after a gunman killed at least 30 UK tourists in an attack on Friday that British politicians have described as the single worst assault on their nationals since the bombing of the London underground in 2005.
The attacker has been identified as Seifeddine Rezgui, a 23-year-old aviation student from Tunisia's Kairouan University, where he had been living with other students.
The attack was claimed by ISIL, but the Tunisian government has disputed this.
The UK is part of a multinational coalition conducting air strikes against ISIL in Iraq, and has sent soldiers to train Kurdish forces battling against the group.