The former Beatle will talk to host John Wilson about his music career and answer questions from the audience at the BBC’s Maida Vale studios on Wednesday May 11.
The hour-long special edition of the programme will broadcast on BBC Radio 4 at 10am on Saturday May 28, and a version will be filmed for BBC iPlayer.
Wilson said: “Mastertapes looks at the nuts and bolts of songwriting and draws back the curtain on what can often be a private and sometimes lonely art.
“Having interviewed McCartney many times before, I know he offers great insight into that process.
“As the most successful songwriter of all time and the man behind some of my favourite music, I couldn’t ask for a better guest – it’s going to be a very special session.”
On the programme, musicians and artists join Wilson to discuss their career-defining albums.
The shows are usually broadcast over two consecutive days.
Each edition of Mastertapes involves an in-depth interview with the artist, known as the “A-side”, questions from the studio audience for the “B-side”, and exclusive live performances of songs from the albums under discussion.
Former guests include Noel Gallagher, Robbie Williams, Natalie Merchant, Manic Street Preachers, Sinead O’Connor, Paul Weller, Corinne Bailey Rae and Rufus Wainwright.
A limited number of audience tickets for the conversation with Sir Paul will be available for 24 hours from 12pm on Wednesday on the Mastertapes page on the Radio 4 website.