Gerrard will also miss England's two summer friendlies against the Republic of Ireland on May 29 and Brazil on June 2.
Gerrard had been expected to have the operation later in the summer but the Reds have decided he should not delay any longer and he will go under the knife this week.
Liverpool confirmed: "The captain's injury has progressively worsened in recent weeks and requires an operation to cure it.
"Gerrard will now miss the final two games of 2012-13, but he is expected to be fit for the start of pre-season training this summer."
Gerrard, 33 later this month, has had his best season fitness-wise and his appearance in Sunday's 220th Merseyside derby was his 36th consecutive Premier League start - equalling his previous longest run set between April 2006 and April 2007.