First off, you're mixing two things: copyright violation and plagiarism. They are completely different.
The point of copyright law is to protect the financial interests of the writer. If you copy someone else's work and sell it as your own, then you are costing the original author sales. Court cases on copyright center on whether the copied work would cost the author sales or not.
Plagiarism is an academic violation. The point of rules against plagiarism is that you are claiming credit for something that you didn't do. Part of the issue is that it deprives the person who really did it of the honor that he deserves, and part of it is that it makes if difficult for others to study the history and development of an idea because you are breaking the chain of references.
All that said:
Avoiding plagiarism is easy: Give a proper footnote. Plagiarism is mainly of interest in scholarly pursuits. Parody is unlikely to be scholarly, so it's mostly a non-issue. But if you're worried about it, just give a footnote saying, "This is a parody of ..." and you're covered.
There is a special clause in copyright law for parody. The nature of parody is that you have to copy the original work to some extent. If readers can't see an obvious connection between the parody and the original, than it's not a parody, by definition. So the legal lines get blurred. On the one hand the more you copy, the more likely that a court will say you have violated someone's copyright. But if you don't copy enough, it won't be understood to be parody. Courts struggle with this regularly.
I am not a lawyer so that's about as far as I can go in answering the real question. I would GUESS -- again, speaking as a non-lawyer -- that if, say, you took the script of Star Wars and everywhere it said "Darth Vader" you replaced this with "Barack Obama", that this might be called parody, but would not be transformative enough to escape a charge of copyright violation. But if you went throughout the story and made numerous changes to insert references to contemporary politics, while keeping enough of the original so that it was still clearly recognizable, that you would win if sued. But there are no fine lines in the law. Nowhere does the law say, "you can copy 60% but not 61%" or any such specific numbers. It's up to the judgement of a court. And remember, the real criterion is: is it likely that you will cost the original writer sales? Will people buy your version INSTEAD OF the original? If so, you are likely to lose. But if you can convince the court that no one would confuse your parody with the original, and that indeed you might even increase sales of the original if people who hadn't seen the original read your parody and say, hey, I have to get a copy of the original to understand this, then you'll win. And the author of the original probably wouldn't sue in the first place.