Bayern Munich midfielder Javi Martinez is to undergo groin surgery and will be out for the next three weeks.