Suppose that I distribute my own code with a GPL license, even though the code use just external MIT or Apache code. In particular, no preexisting GPL code is in it.
Can I later relicense it under MIT or Apache?
Open Source Stack Exchange is a question and answer site for people organizing, marketing or licensing open source development projects. It only takes a minute to sign up.Sign up to join this community
As the copyright holder you are in no way bound by any open source license you choose to distribute your own work under.
While you cannot retroactively change the license terms of a particular distribution of your software for those who have already obtained it, you can permit use and re-distribution under the terms of a more permissive license of any distribution of your software however and whenever you like.
If you hold the copyright to some code (usually, because you are the author), you may license that code however you please, and you may issue different licenses at any time. The matter of revoking previously-issued licenses is much trickier and may not be possible. If you have previously issued permission to modify/distribute your code under some version of the GNU GPL, nothing stops you from also issuing permission to modify/distribute the code under a different license like the Apache License.
Note that if you have accepted contributions from any other person, those contributions may be under your original license, licensed to you by that other contributor. You may not re-license another person's code, unless they allow you do so, either by your asking nicely or via a previous agreement like a Contributor License Agreement.
In practice, your code is usually as permissively available as your most permissive license grant. If you had the reverse situation -- your code was under Apache and you want to re-license it under the GPL -- you could issue a GPL grant, but you could not take away the more permissive license grant you already made to any recipients who already downloaded it. People might be more likely to get the permissively-licensed version from someone else than use your more restrictively-licensed version. However, you could issue new code under the GPL only, making users choose between the old permissively-licensed code and the newer version with copyleft-licensed code.