Tex/Latex have what is called monolithic state: you can't cleanly isolate the configuration done by one package from another, which is one of the reasons why incompatibilities are possible. This means there is no way to identify how to undo what changes the
\usepackage command has caused. Think of installing software on your machine: if the software makes lots of changes to operating-system -specific files, and doesn't put together an uninstall script, there is no good way to uninstall the software short of reinstalling the operating system. The situation here is similar, so as Werner says, your reversible
\usepackage is impossible.
From the main comments, you say: only package A is used in the main texts, while only package B is used in the appendix?
This suggests that the
pdfpages package might work for you, if the package conflict really is unsolveable. The workflow would be that you split the document in two, compile the appendices separately and import the PDF output of the appendices at the end of the main document. See Base document page numbers with pdfpages for an explanation of how to get page numbering to work properly in this case.
This is not usually as good a way as working as compiling everything in one document, because Latex will lose whole-document content: it can add numbers to your pages and keep track of how long your appendices are, but it does not put subsections in the table of contents, or keep track of tables and figures, or references. For that, though, there is software that tries to build up this overall picture by trying to join together information from the separate compilation processes (via their .aux files): see T. Verron's example and the