Can earth escape sun's gravity with the help of a black hole heading towards our solar system? To escape the Sun's gravity, the Earth would need sufficient amount of energy. Let's say a stellar black hole has entered our solar system and at a certain distance from earth, the black hole exerts same and equal gravitational force on the Earth as the sun is exerting. Earth feels a zero net force. Will it help earth to fly away?

Assuming the black hole had an empty stomach before eating our solar system.
There is no need to hypothesise a black hole. A black hole's gravity is indistinguishable from that of a similarly sized star, except in the region closely surrounding the event horizon.

Black holes can't be only 1 solar mass, there is no known mechanism that could cause a single solar mass object to undergo complete collapse. Black holes have at least three times the mass of the sun.

So could a massive star disrupt the orbit of Earth? Yes it could. If the star were to pass by the Earth, it could cause a slingshot effect, transferring some of it's momentum to the Earth, which could cause Earth to leave solar orbit.

In the precise situation that you describe, Earth would initially be travelling in a straight line, but then would follow a complex and possibly chaotic path, as the sun and the black hole pass each other. It is quite possible that the Earth could be ejected, or transferred to an orbit of the black hole in that case.

Fortunately the gaps between stars are so vast (and black holes even more widely spaced) that in the nearly 5 billion years of the Earth, not one has come close enough to cause major disruption to Earth (we know because we are still here).