Permanent Anything in 5E is basically impossible, because Wish exists. If the character stripped of magic can convinced someone to Wish their magic back to them, and they phrase the Wish well enough...then whatever permanent effects you established are undone.
Thus, I have to somewhat challenge the frame of the question. Because Wish exists, even capital punishment, maiming, cursing, etc. cannot permanently bar anyone from using magic. So, as I do not believe the question as-asked can be answered, I must revise the question: How can you remove magic from someone so that it is as hard as possible to get it back?
Well, you have a few options...
Feeblemind
RAW, the simplest way to strip someone of spellcasting ability is the spell Feeblemind As part of the spell description, it explicitly says:
The creature can't cast spells, activate magic items, understand language, or communicate in any intelligible way.
Now, this is quite certainly cruel and unusual punishment. You've turned someone into a shattered husk of a person that is in a state little better than a vegetable.
That said, it requires a 5th level spell (at the lowest) in order to undo (Greater Restoration), though Heal and Wish will also do the trick. Coupled with something such as a Criminal Brand in a highly visible location, and laws that state that anyone found guilty of removing a Feeblemind spell from someone so branded (or removing the brand) will be subject to a Feeblemind spell themselves. That should make it quite difficult to find a spellcaster of high enough level to cast the spell, and willing to take that risk.
In short, in order to get a Criminal Feeblemind removed from you, you'd need to find a 9th level spellcaster who is willing to take the risk of having a truly horrific punishment imposed on them to use Greater Restoration on a known criminal. And if Feeblemind is a publicly known punishment for the worst of spellcasting criminals...then any spellcaster who is not freely willing to risk their mind and magic who is presented with someone afflicted with Feeblemind and asked to cure it is going to check with law enforcement before they cast the spell.
All of this bearing in mind, of course, that the criminal is incapable of communicating on their own behalf. So they also have to find someone else willing to risk being Feebleminded in order to do the searching for a healer on their behalf
Wish
As an additional option, Wish is always on the table. But, using Wish to directly strip someone's magic from them is risky, as that is not one of the 'prescribed uses' of the spell, and carries the risk of losing the ability to ever cast Wish again. Thus...this is not really practical as a form of criminal punishment.
Now, to move to a slightly less RAW option, but is instead one that follows logically...
Divine Intervention
A high level Cleric of the god of Magic (in The Realms, this would be Mystra, so I'm going to use that name going forward) asks Mystra to take away the target's magic. Whether or not this works would be entirely up to your DM, but it does make logical sense and, if he's on-board with your idea of how to replace your character, he may give you the thumbs up. Simply put, the Cleric of Mystra uses Divine Intervention to ask Mystra to sever the target character's connection to The Weave of Magic.
Canonically, according to Realms History, Mystra once re-wrote the rules of magic on a cosmic scale (in the aftermath of Karsus's Folly). I would imagine she'd be quite capable of stripping someone's ability to use magic away from them. Again, this could almost certainly be undone using Wish, but that's true of literally anything.
Other
From here, you're soundly in homebrew territory. As the DM has the ability to make stuff up and add it to the game at will, it wouldn't be all that hard to create a ritual or spell or something with a long cast time that serves to permanently shut down magic.