Stoke had agreed an undisclosed fee for Ba with Hoffenheim earlier this week and the move was expected to go through.
Stoke chief executive Tony Scholes said: “Having agreed all the financial terms of the deal with Hoffenheim and the player, he failed his medical.
“We will therefore not be signing him on a permanent basis.”