A musical parody involves changing existing recognized musical ideas or lyrics. Permission from the owner of the copyright is generally required before commercial exploitation of a parody.
However, in the US, the law has ruled in some cases that the parody was a fair use. This was the case in the mid-1990s when Campbell v. Acuff-Rose Music, Inc. was brought before the U.S. Supreme Court by country music legend Roy Acuff's music publishing company against the lead singer of the rap music group 2 Live Crew for recording a lewd version of one of Acuff's songs without his permission.
It was found that the commercial nature of a parody does not render it a presumptively unfair use of copyrighted material. Rather, a parody's commercial character is only one element that should be weighed in a fair use inquiry. In short, this means it's on a case-by-case basis.
This created a legal standard for parody as protected derivative work. However, the line is not always clear and it is best to get permission from the original copyright owner before registering a work to avoid copyright infringement (which is punishable by law).
The most successful parodist of popular music is often considered "Weird Al" Yankovic, who gets prior permission before releasing his parodies.
This may vary depending on your country. You can find more information on copyright law here.