The attacker, a 25-year-old who went to jail in 2013 for helping Islamist militants go to Pakistan and had been monitored by security services, repeatedly knifed the 42-year-old commander in the stomach late on Monday.
He then barricaded himself inside the house in Magnanville, a suburb some 60 km west of Paris, taking the policeman's partner and three-year-old son hostage. His partner, an administrative police official, was found dead in the house. The boy was unharmed but in a state of shock, an Interior Ministry spokesman said.
The man, whom police and justice sources named as Larossi Abballa, was shot dead by members of an elite police unit after negotiations failed.
"An abject act of terrorism was carried out yesterday in Magnanville," Interior Minister Bernard Cazeneuve said after an emergency government meeting, before heading out to Les Mureaux, where the police commander worked.
President Francois Hollande said the killings were "undeniably a terrorist act" and that the terrorist threat in France was very high.
The killings took place as police forces throughout France were on high alert for attacks during the Euro 2016 soccer tournament which began last week.
Islamic State claimed the attack via its Amaq news agency. "Source to Amaq agency: Islamic State fighter kills deputy chief of the police station in the city of Les Mureaux and his wife," Amaq said on its website.
If it is confirmed Islamic State was behind the murders, it would be the first militant strike on French soil since the government imposed a state of emergency after multiple attacks on Paris in November that killed 130 people.
Islamic State's claim that one of its "fighters" carried out the evening attack came a day after the Islamist militant group said it was responsible for the shooting that killed 49 people in a massacre at a gay nightclub in Orlando, Florida.
Searches were being carried out on Tuesday morning at the attacker's house and in other places, a judicial source said. "Many things are being analyzed," the source said, including messages posted on social networks.
The police commander's partner was also killed with a knife, the source said, but declined to give any more details. Larossi was born in France, said the source.
Larossi was given a three-year prison sentence in 2013 for helping Islamist militants go to Pakistan. His name had come up in an ongoing investigation about a man who left for Syria, but he was not considered a threat, another source close to the investigation said.
Officials have not revealed the identity of the 42-year-old officer.