The clash will be the first time Gerrard has played at the ground since calling time on his playing career in November 2016 and joining the club as an academy coach earlier this month.
Gerrard will line up alongside fellow legends including Ian Rush, Robbie Fowler, Jamie Carragher, Luis Garcia and John Arne Riise.
Gerrard said: "I'm really looking forward to playing in the LFC Foundation Legends Charity match - Anfield will always hold a special place in my heart.
Gerrard has since returned to Liverpool as an academy coach.
"It's a real honour to be sharing the pitch with such a great team of legends whilst raising money for the club's official charity."
All proceeds will go to the LFC Foundation - the club's official charity. Funds raised will support the charity's programmes and partnerships, which aim to improve the health and life chances of children and young people in Merseyside and beyond.
Andrea Cooper, head of the LFC Foundation, said: "We are delighted that Steven will be joining us for the first official Legends game to be held at Anfield. It promises to be a fantastic day for all involved.