The Czech, who is 25th in the ATP rankings and was seeded 22 for Wimbledon, said Thursday he suffered the injury in training on Monday.
"I just felt pain all of a sudden, and my leg started shaking," Stepanek said.
"On Wednesday I went for an MRI (magnetic resonance imaging) scan and I have to pull out of Wimbledon as well as the Davis Cup."
Stepanek was also scheduled to play in a Davis Cup quarter-final against Chile on July 9-11 in Coquimbo, Chile.
The Czech has been sidelined from the courts since March due to fatigue.
Wimbledon starts on Monday.