Actually, the Lord Commander DOES have the power to relieve someone of their oath. In fact, the Lord Commander and the King are the only two men who can do so. When asked that very question in an online chat, GRRM responded thusly:
User: Is there any chance that Jon could be released from his oaths of
the nightwatch?
George_RR_Martin: The great council would have released Aemon from his
maester's oath, so I suppose it would be possible. With an appropriate
authority.
However, in this case, that wouldn't be necessary. Sam would be attending The Citadel to become the Maester for the Night's Watch, which is perfectly acceptable. Upon his graduation, Sam would be expected to return to Castle Black and resume his duties (unless otherwise noted).
Maester Aemon reveals this dual loyalty when he reveals his identity to Jon Snow:
Jon Snow: You're a Targaryen?
Maester Aemon: I am a maester of the Citadel, bound in service to
Castle Black and the Nights' Watch. I will not tell you to stay or go.
You must make that choice yourself, and live with it for the rest of
your days — as I have.
As others have mentioned, it's also not unusual for a Night's Watch brother to be away from The Wall on temporary assignment, which is basically what Sam's time at The Citadel would be. Brothers of the Watch are often sent on recruitment drives to King's Landing and other large cities, as well as supply runs & "funding" drives. For example, the official reason for Benjen Stark's visit to Winterfell was to petition King Robert regarding additional funds & men.