A memory wipe was a method that was used to selectively or completely
erase the memory of a droid. After Cad Bane had kidnapped and
ransacked the memory of C-3PO and R2-D2 for information on the Senate
Building's layout, he only had the incident wiped from their memories
to avoid having any suspicion falling on him. Shortly after the
Galactic Empire was formed, Bail Organa had C-3PO's memory wiped clean
in order for the droid to not spill any confidential information. When
he purchased C-3PO and R2-D2, Owen Lars also wanted the droids'
memories wiped after he learned they were looking for Obi-Wan Kenobi.
Memory wipes were an important process, and the lack of one could
allow droids to develop new ideas. This happened with the mining droid
STALKER-1, who turned into a hunter after years without a memory
reset. Memory wipes were far from perfect, however, and both C-3PO
and the First Order droid O-MR1 both experienced flashes of erased
memories. A macro protocol could be used to wipe the memories of
multiple droids simultaneously.
The Galactic Empire did not grant its droids any independence and
sought to keep them subservient and docile. Part of this process was
frequent memory wipes in order to keep them from getting independent
So although this does not explain the mystery of why R2-D2 did NOT have his memory swiped at this time, it does confirm the idea that C-3PO would be a droid that would be prone to giving out pertinent information, given the characters penchant for excessive rambling and storytelling.
The wookieepedia article also makes point that memory or memory-swiping is something slightly thematic to Star Wars, particularly with droids and a few of the ways memory swipes can be used in different ways from espionage tactics with hiding information to themes about slavery and [identity] suppression.