Baines injured his ankle during Everton's 2-0 loss to Sunderland on May 9 and was later advised to undergo surgery.
"Leighton had a bit of instability in his ankle that flared up and it was painful in the last game. It needed repair work so he had surgery on Wednesday," Everton manager Roberto Martinez told reporters on Thursday. "It was a straightforward operation to clear the ankle and give it stability. He'll be out until the start of pre-season, but it's what he needed, he was trying to play through the pain barrier.
"It's been a problem since 2012, it's been showing signs it needed work. He saw the specialist yesterday and we're looking forward to getting him back.
"It's a situation where it doesn't affect you for a period then you get a knock and it flares up, that's what happened. It was quite difficult for him to play pain free, the advice from the specialist is to treat it well and make sure the ankle is perfect going forward.
Baines is also set to miss England's friendly against the Republic of Ireland and their Euro 2016 qualifying match against Slovenia next month.
However, Martinez expects the 30-year-old defender to be fully fit prior to pre-season training in the summer.
"We look forward to seeing Leighton with a period of getting fresh and getting ready for the next campaign," he said. "The way Leighton is, he doesn't want to miss playing and always puts himself forward to play.
"When you're not pain free it can be difficult and it was evident against Sunderland."