But i want the callback on the remote system to work only during some times otherwise it is done locally
I don't believe that is how publish-subscribe works -- or at least, not in the default implementation in ROS 1.
At the user/application level, there is no knowledge/state your publisher has access to that would allow it to actively influence which subscribers receive messages, neither whether they have actual callbacks registered for those messages.
In addition: publish-subscribe (again: as implemented in ROS 1) provides location transparency: nodes do not "know" where other nodes are (or where they are deployed).
So "the callback on the remote system" is not something that you can say given these two properties.
But this is all at the user/application level, the middleware obviously does know where other nodes are (see also #q203129).
A naive way to do what you describe could be to deregister your subscribers whenever they are not needed. Then resubscribe again when the need is there. Provided you're not doing that multiple times per second that should not incur too much latency / performance overhead.
Perhaps this is a use-case for ros::topic::waitForMessage(..).
Alternatively: if control over where (and when) processing takes place is important, it could be that services or actions are a more suitable interaction pattern.
A general comment: you now have 5 questions posted of which 3 received a answers. It would be good if you could go back to those questions and see which of the answers actually solved your problem. Then accept those answers.