The speed at which you need to throw the ball is called its escape velocity. But imagine increasing the mass of the Earth more and more. The speed required to escape the gravitational pull also increases. But there will be a point at which the mass of the Earth is so big that the ball would need to be launched at a speed faster than the speed of light in order to escape. At this point the ball is trapped. It cannot go beyond a certain point before it is pulled back to Earth.

