They will travel to the European country in June after an invitation from German President Joachim Gauck.
This will be the Queen's seventh time in Germany - her first was in 1965 and the last in 2004. In 2000, she opened the new British embassy in Berlin.
She has been on four previous state visits and two official visits.
Buckingham Palace said in a short statement: "The Queen, accompanied by the Duke of Edinburgh, will make a state visit to the Federal Republic of Germany from 24 to 26 June.
"Her Majesty and His Royal Highness are visiting at the invitation of the President of the Federal Republic of Germany, Joachim Gauck."
Mr Gauck and his partner, Daniela Schadt, were guests of the Queen and Prince Philip at a lunch at Buckingham Palace in November 2012.
Mr Gauck, a human-rights campaigner and former East German dissident, became president in March 2012.
The Queen and the Duke of Edinburgh will make a three-day state visit to Germany this summer, Buckingham Palace has announced.