
Robertson has enjoyed six Super Rugby titles, two of them share with O'Gara, while the former Irish and British & Irish Lions five-eighths has gone on to greater heights as head coach of French club La Rochelle.
O'Gara's side won the European Champions Cup when beating Irish club Leinster in May.
The game, at Tottenham Hotspur Stadium in London, will be the first international rugby game to be played at the venue.
O'Gara told balls.ie, he was honoured to coach the Barbarians.
"It will be a dynamite coaching team, and I'm very much looking forward to reuniting with Ray after my time with him at [the] Crusaders. It is always great to join forces with world-class coaches like him, and to do so for this world-famous club will be an unforgettable experience," he said.
Robertson said: "Rugby throws you great opportunities and coaching the Baabaas has to be one of the best there is. I am proud to help the incredible club and add to its history."
O'Gara added, "We're going to put our heads together in the coming months and devise a squad of exciting talent who will light up the pitch at Tottenham Hotspur Stadium and bring the Barbarians' style of play to live against the All Blacks XV."
The teams will play for the Killik Cup.
Barbarians president John Spencer, the former 1971 British & Irish Lion, said, "Playing at Tottenham Hotspur Stadium will also give our spectators a truly exceptional experience. While this state-of-the-art stadium has hosted club rugby matches, this is the first time it will play host to an international rugby fixture.
"The Barbarians are no strangers to playing historic matches at newly-opened stadiums. In 2008 we played Australia at the new Wembley Stadium and in the build-up to Rugby World Cup 2015 we played Samoa at the Olympic Stadium – now the London Stadium – in Stratford's Queen Elizabeth Olympic Park."