The Reds will host Greek champions Olympiacos at Anfield on Saturday, 3 August (KO 2pm), with both clubs donating the proceeds to charity.
Gerrard's dramatic late goal against the Greeks in December 2004 sent Liverpool through to the knockout stages of the Champions League and he went on to lift the trophy the following May.
"I am delighted to be honoured by Liverpool FC with a testimonial match and particularly thrilled that Olympiacos have accepted my invitation to play the fixture," Gerrard said.
"Last time we met proved to be such a memorable game both for me personally and Liverpool Football Club.
"I am also especially grateful that Olympiacos have truly embraced the aim of this match and chosen to donate their fee to charity. I am looking forward to what I know will be a fantastic game and a wonderful occasion."
Liverpool will donate monies raised to The Steven Gerrard Foundation, a charity for disadvantaged youngsters, while Olympiacos will give their appearance fee to local causes back home.