The military offensive against Taliban militants entrenched in north-western Pakistan is nearly over, the defence minister has said.