The answer to this question is complex and subjective. The fact is that there will be situations where you want to do one thing and there will be situations where you want to do another. I'll do my best to give a sort of primer on why this is the case.
When soloing/improvising, it is good to think of a scale as a tool. What this tool does is give you a way to categorize notes as being related to each other and also having some sort of relationship with the underlying harmony (if applicable). Any combination of notes is going to have a relationship, and as a soloist you want to manipulate that relationship in a way that conveys whatever you're trying to get across. This is an exceedingly dry way to describe music, but it's necessary to get into that kind of head space when looking at something like this.
To your question then: Should you only utilize the A minor pentatonic scale when the underlying harmony is in A minor? The answer to this is absolutely not: Going back to what I said about scales as tools, pentatonic scales are extremely flexible tools that, by virtue of what it lacks compared to their diatonic cousins, can be used in a wide variety of contexts. If you're just looking for the short answer, you can probably stop reading here; the main answer to your question is simply that you should be experimental, particularly with tools as flexible as pentatonic scales.
The long answer is that sometimes you want notes that sound consonant and sometimes you want notes that sound dissonant. Playing A minor pentatonic over an A minor chord is going to give you a lot of consonance:
A Minor | A Minor Pentatonic
ACE | A C D E G
You can see, first of all, that the A minor Pentatonic scale consists mostly of notes that are in an A minor chord. These notes are all going to sound pretty consonant, because they're literally in the chord. Unison is about as consonant as it gets. G is going to sound pretty consonant too, as it's simply the logical seventh of A minor. D has some degree of underlying dissonance to it but in the 21st century you are unlikely to hear anyone describe the relationship between D and an A minor chord as "dissonant".
Let's look at A Minor pentatonic over some other chords. I'm going to use seventh chords because they're more harmonically interesting and if you're soloing that's likely what you're going to encounter, but you can ignore the seventh if you really want to.
So in this chart I've included the name of the chord I'm comparing A minor against, the notes of that chord, what notes from A minor Pentatonic are likely to be interpreted as consonant, what notes are likely to be interpreted as dissonant, and what notes are likely to be interpreted as "wrong" notes. What I mean by wrong note is generally that the note in question betrays the function of the underlying chord. This is something you almost never want to do because it's extremely dissonant and confusing for the listener. Examples of this include repeatedly playing an F over a C major chord or playing a major third over an explicitly stated minor chord (note, however, that the other way around is generally fine). The first example of this you'll see is E over F7; outside of a blues this is a combination of notes that you will almost never see.
Chord Name | Chord Notes | Consonant | Dissonant | "Wrong" Notes
DMi7 D F A C A C D E G
Emi7 E G B D A C D E G
F7 F A C Eb A C D G E
BbMaj7 Bb D F A A C D E G
D7 D F# A C A C D E G
Ab7 Ab C Eb Gb C D A E G
Ab7b9 Ab C Eb Gb Bbb A C D E G
C#mi7b5 C# E G B E C D G A
You could keep doing this kind of analysis for every chord in the book, but it's not necessary. The point is that as you can see a pretty high percentage of the scale remains usable, even over chords that seemingly have no connection to A minor pentatonic. You probably don't want to go in on some A minor pentatonic runs over F7 because that E stands out like a sore thumb, but you could simply flat the E and use that instead (giving you ACDEbG).
This works the other way too; chords can take many, many different pentatonic scales to produce different outcomes:
Chord | Scale | Outcome
Ami A minor Pentatonic Very consonant. Duh
Ami D Minor Pentatonic Still very consonant, although somewhat less so because of F.
Ami E Minor Pentatonic Also very consonant. Has no notes with dissonant relationships to Ami.
Ami Bb Minor Pentatonic Extremely dissonant. Probably too dissonant.
Ami B Minor Pentatonic This will make the Ami sound dorian/like an Ami6/9.
Ami Bb Major Pentatonic Bit of a Phrygian relationship.
Ami Eb Minor Pentatonic Please don't do this.
Again, you can do this pretty endlessly. Note that the relationship here isn't random: The closer the key of the scale you're playing is to the key of the chord, the more consonant it's going to sound. If you really want to go as far out as possible, the best way to accomplish that is to play the parallel scale a tritone away from the chord. In other words, the best way to get as dissonant as possible is to play the scale as distant as possible.
This is a very complex subject and my analysis here is far from exhaustive; I've only discussed one type of scale for one type of chord.