The title is pretty self explanatory, is there a good way to switch between scales while playing? Like is there a technique? or do you switch when it sounds good, haha. Major and Pentatonic scales.

usually you'd switch scales because the "feel" of the song changes so if you wanted a slightly different feel you could switch and the band could follow... but a lot of the time you can just interchange between different scales mid-solo and most experienced / jazz players do so
i know exactly what you're talking about and i've had some troubles as well. i think it sounds okay if you switch between two scales (i use the all of the blues scales, which cover the whole fingerboard) while on a root note. try to make the switching sound fluid too, use some slides and get your fingers ready for pull offs into the next scale. sorry if that doesnt make sense but its what i do and with some practice it sounds pretty good.
We are the music makers, we are the dreamers of dreams.