Masekela was part of a group of high-profile artists who entertained the queen and a royal delegation that included Prince Charles and his wife, Camilla.
Commonwealth Day is held each year on the second Monday of March to celebrate the British Commonwealth.
Masekela, who is an outspoken advocate of civil rights, belted out an anti-war song.
Before singing, the jazzman told his audience: "With this great song that I have done with Caiphus Semenya, we call on the people of the world to cease contemplating war against each other."
Canadian musicians Rufus Wainwright and Laura Wright, Nigerian-born writer Chimamanda Ngozi Adichie and the Descarga Dance Company also performed .
Queen Elizabeth, in a pre-recorded address, stressed the importance of cultural connections in the Commonwealth family.
"This year, our Commonwealth focus seeks to explore how we can share and strengthen the bond of Commonwealth citizenship we enjoy by using our cultural connections to help bring us even closer together as family and friends across the globe," she said.
The 54-nation Commonwealth consists mostly of states that were part of the British Empire.