It is understood an initial £7.1million fee had been agreed - as well as personal terms - for the Senegal international.
Ba, 25, visited the club's Clayton Wood training ground for a medical, only to be given the bad news.
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."
Source: PA
Source: PA