He gave the order at a swearing-in ceremony for the new service commanders he appointed last month.
When Mr Buhari took office in May, he vowed to tackle the six-year Islamist insurgency “head on”.
He has made a boosted multinational force of 8,700 central to his strategy in tackling the crisis.
At least 17,000 people have been killed since Boko Haram launched its insurgency in northern Nigeria 2009, according to Amnesty International.
Although the militants have lost their strongholds, they are still active and there has been an upsurge in suicide attacks since Mr Buhari took office.
There have also been more attacks in neighbouring states.
The BBC’s Randy Joe Sa’ah in Cameroon says suspected Boko Haram militants killed five villagers and a soldier on Wednesday night.
The militants entered the village of Lame, near the town of Fotokol in the Far North region, almost silently using horses and bicycles, a military source said.
They burnt down homes and schools and managed to escape before army commanders arrived at the scene.
President Buhari – a former army general – reiterated that the new military chiefs would be expected to work closely with neighbours Chad, Cameroon and Niger in fighting Boko Haram.
He said he would give troops the necessary resources to achieve the “feat”.
But the president urged the armed forces to abide by the law when fighting the militants.
“In particular you must protect innocent civilians and respect the rights of combatants,” he said.
The US has refused to sell arms to Nigeria, citing human rights abuses.
Two of the commanders Mr Buhari has appointed – Maj Gen Tukur Yusuf Buratai, and the National Security Adviser, Maj Gen Babagana Monguno – are from north-eastern Borno state, which is at the heart of the conflict.
Analysts say the president hopes this will enable them to have a good handle on what is needed to end the violence.