What are the parameters and conditions of when one is allowed (and not allowed) to ask another Rabbi once he/she got a Psak from the first Rabbi?
Rav Aryeh Kaplan in his Collected Writings quotes the Shach as far as the exact parameters pertaining to this question. His basic points are:
In order to ask another posek one must have real reason to doubt the correctness of the first psak.
(As Shalom stated) One must tell the second posek that he already received a psak from posek #1.
The 2nd posek must rule on whether the first posek was mistaken and disregarded (or was ignorant of) a d'var mishnah, a clearcut and easily known unanimously held halachic decision.
If posek #2 rules that posek #1 made such a mistake, then one is free to ask posek #2 for his opinion.
If posek #2 just disagrees and cannot state a case for proving that posek #1 made a mistake on a clearly stated halacha then one may not leave posek #1's position in favor of posek #2's decision even if one feels that it makes more sense.
I am writing this from memory of Rav Kaplan's book, the Shach (I looked it up at the time I read R Kaplan's essay), and the Rosh (who is probably based on the Tosafos YS is referring to) so this is possibly an incomplete guide but it has the basics as I can recall them.
If I find online links and when I get ahold of the exact sources I will bl"n put them on to this answer.
I believe the Kitzur Shulchan Aruch says you must tell Rabbi #2 that you already asked Rabbi #1 (and honestly convey both your question as posed to him, and his answer!).
The Chochmas Adam has more guidelines on dealing with poskim and psakim; hopefully I'll have more info later.
This assumes that rabbis 1 and 2 are just random rabbis you ask.
However, sometimes a rabbi is in a position of exclusive authority over a certain sphere, at which point it could be obligatory to follow his rulings vis-a-vis that sphere. Rabbi Mordechai Willig believes that an Israeli soldier may ask his home-town rabbi a personal-only question like "what text should I use for my personal prayers?" Any question affecting the army's performance must go to an army rabbi. (Though Rabbi Gil Student cites a differing view here, that one may confirm with one's personal rabbi that the army rabbi's psak was within the boundaries of reason.)
All of the dinim can be found in YD 242:31 in the Rema. The Shach there disagrees with a lot of the Rema's psakim, but the Aruch Hashulchan says we hold like the Rema over the Shach on this one (there's no Mishnah Brura since its in YD)