The Spanish midfielder has been carrying the injury for several weeks and has now decided to go under the knife rather than continue with more conservative treatment.
"I don't have any problem for 20, 30 minutes, but then I start feeling pain again," said the 25-year-old after last Friday's UEFA Super Cup victory over Chelsea.
Bayern club doctors advised him to undergo an operation to eradicate the problem, even if it rules him out of Bayern's first Champions League fixture of the season against CSKA Moscow.
"I'm on my way to the clinic for an operation," Martinez wrote on Twitter on Tuesday. "I'm sure it will all go well."
Bayern are also without Mario Gotze, Bastian Schweinsteiger and Thiago Alcantara and could therefore be short of midfielders when they face Hannover after the international break.