Here's another writing topic suggested at Facebook: How do you use or quote material from other sources in a book? This would include stuff like song lyrics, movie quotes, poems, or passages from a novel.
I've avoided using any material that would require permission, so I'm not going to try to get into how to do that. Instead, I'll talk about how to avoid doing something that requires permission. Keep in mind that I'm not a lawyer or an expert, so you might need to consult an expert, depending on your case. I'm basing this on observation from years in the industry, some workshops on the subject, and a semester of media law in journalism school.
First, I want to clarify a couple of definitions: copyright infringement is any use of copyrighted material without permission from the copyright holder -- even if you attribute the source. This can include not only the actual words but also things like characters and settings. I can't write books about the continuing adventures of Harry Potter, even if I write them all in my own words, and I can't write books about the next generation of students at Hogwarts, even if they're all original characters. Plagiarism is stealing someone else's words and passing them off as your own.
But there are some ways in which you may be able to use attributed material from others without getting permission.
1) Fair Use
The Fair Use doctrine has a lot of gray areas, but it generally allows you to make references or allusions to other works -- your characters can talk about movies, books or TV shows. Satire and parody are also considered fair use, but you may wind up going to court to prove that it really is satire or parody and not a copyright infringement. You can also quote small amounts that aren't a substantial percentage of the work. With a novel, movie or play, you can quote a line or two because that's a tiny portion of the whole work. Now, I have seen lists of "used with permission" for quotes in books, so this may be something handled on a case-by-case basis, and it probably depends on how it's used (this is when you need an expert). Because songs are so short, it's generally considered that quoting any part of a song lyric is considered using a substantial portion of the song, so to use song lyrics or quotes from non-epic poems, you'll need to get permission from the copyright holder, and for songs especially, payment may be involved. The more well-known the song, the more you may have to pay. You may be able to work out a deal with an independent, up-and-coming songwriter to use lyrics in exchange for a link on your web site and attribution in the book, but if you want to use Rolling Stones lyrics, you'll have to pay for it -- and it usually is the author, not the publisher who has to handle this.
But there is a way around the process of getting permission to use song lyrics. The title of a work is not considered to be under copyright, so you can name all the song titles you want as long as you don't quote the lyrics. If it's a well-known song, that generally does the trick. If you write something like, "'Bohemian Rhapsody' came on the radio, and she cranked up the volume and sang along, hitting all the high notes with Freddie Mercury," you probably have the song pop into your head even without the lyrics. In fact, quoting lyrics generally just slows down the story (and, frankly, makes something read like fan fiction written by a teenager).
3) Public Domain
Meanwhile, there's a vast library of material that's no longer under copyright that's fair game. You can quote from it, use the characters, use the setting, write sequels or even publish your own editions. Properly attributed, of course. Copyright laws keep changing, so it depends on when a work was written when it goes out of copyright, and some authors or their estates manage to renew copyright on a work. In some cases, elements of a work may be trademarked, which means those elements can't be used even if the original work is in the public domain. A good guideline is that something available at Project Gutenberg is in the public domain, but you'd need to verify this before using some work.
Most "classic" literature falls into this category, as do many hymns and folk songs and most folklore, mythology and fairy tales. But there are some cautions.
Some things we think of as "classic" are more recent than you think. The hymn "How Great Thou Art" seems like an old standard, but it was written in the 1950s. With folk songs and hymns, new verses may have been added, and those verses might be under copyright. If you're using something that has been used and adapted often, like a fairy tale, you need to be careful to work from the source material, not the more recent adaptations. For instance, you can write about Snow White and the seven dwarfs, but the "Doc," "Sleepy," "Grumpy," etc. personalities are from the Disney film, not the original fairy tale, so you could be in trouble if they show up in your work. Or there are times when most of the popular images associated with a work are from an adaptation that's still under copyright. L. Frank Baum's novel The Wonderful Wizard of Oz is in the public domain, but most people are more familiar with the 1939 movie, which is under copyright. Dorothy's slippers in the book are silver, but this was changed to red for the movie (I guess silver was considered a waste when shooting in the new, exciting color format), so the red shoes are from a copyrighted property (and I believe MGM has also trademarked them). That's probably why in the TV series Once Upon a Time, when they delved into Oz, the slippers were silver instead of the red that a lot of people expected.
Translations are another issue with works not originally written in English because even if the work is in the public domain, a particular English translation may be under copyright. Beowulf is well out of copyright, but you're only safe using a fairly old translation. Ditto for the works of Cervantes or Victor Hugo. The Bible is ancient, but many of the more modern translations are under copyright. The King James Version is safe to use, though.
Using others' material is a decision you have to make depending on how critical it is to your story. Really, quoting long passages of anything makes for boring reading. A passing reference may be all you need to give you the right flavor, and it requires far less paperwork.