Bilal, you need to understand a few things about how people work in jobs, first.
A foreign secretary is not born a foreign secretary. He used to be a diplomat once.
He used to have intensive interactions with senior people in intelligence agencies.
He knows the agency and its functioning inside out.
It's like saying your teacher doesn't know what goes on on the back benches since he never sits there.
The teacher might not sit on the back benches but the teacher very well knows what's going on at the back of the class. This is called EXPERIENCE.
You still haven't answered the question of who exactly the Foreign Secretary of Pakistan collaborates with in the Inter-Services Intelligence. You're right, the Foreign Secretary knows the Ministry of Foreign Affairs inside out, but not the Inter-Services Intelligence. Hell, even the Foreign Minister of Pakistan doesn't know the Inter-Services Intelligence inside out, even though there is communication between him & the Director of the ISI.