The 23-year-old has been troubled by the problem for a number of months and faces being out until around October.
Rashford scored 11 goals in 37 Premier League appearances last season and was in England’s squad at Euro 2020.
“Everyone has an opinion but no one knows my body better than me,” Rashford said in a lengthy post on social media.
“I have read some call me selfish for holding off getting the surgery this season but it was never about putting myself first and that’s how we’ve reached this point, and something as a 23-year-old I have had to learn the hard way.
“To guarantee I can play this game as long as possible I need to listen to my body. When I step on the pitch I always give 100%. Physically my 100% just wasn’t possible.
“I’m walking away from last season with 36 goal contributions, but more importantly I’m walking away with lessons learnt.”
Rashford helped United finish second behind Manchester City in the Premier League last season.
Solskjaer’s side also reached the Europa League final but lost to Spanish side Villarreal on penalties.
Rashford made five appearances for England at Euro 2020 but was only on the pitch for a total of 84 minutes and then missed a penalty in the shootout as Italy beat Gareth Southgate’s side in the final.
Rashford added: “It is hard to describe the feeling of representing your country. Given the choice no one would ever turn that down at such a big tournament. As a little boy or girl you dream of those moments.
“I had been deemed fit for the full season, and given my injuries were being managed, what was another couple of weeks? Managing the pain I was training well and found a lot of comfort in the England camp after the Europa League final.
“In hindsight, if I had known I wouldn’t have played a significant role in the Euros, would I have gone? Hindsight is a wonderful thing isn’t it?
“I didn’t want to let anyone down but ultimately looking at some of my performances towards the end of last season I felt like I was.”
United start their Premier League campaign at home to Leeds United on 14 August, while England play three World Cup qualifiers in September and two in October.
The club said: “Following consultation between Marcus, the manager [Ole Gunnar Solskjaer], club medical staff and specialists, Marcus will undergo surgery imminently to resolve his shoulder injury.
“He will now focus on his rehabilitation in order to return as soon as possible.”