Does the quote have something to do with the title or content of the piece? For example, if the rag or song is about bees you could include quotes extracted from pieces along the lines of
Flight of the Bumblebee or
Honeysuckle Rose. When I play
Row, Row, Row I include a quote from the famous children's round of the same name.
How long is it? I rarely include more than four to eight measures of a quote within a piece. One exception is the inclusion of
Old Folks at Home (Swanee River) in the middle of
Alexander's Ragtime Band, but it clearly works in this context since both the melody and the title phrase are repeated within the song itself. Otherwise, don't lose the focus of the primary melody to an extended quote that creates an unrelated tangent or pulls focus off of the original piece.
Does the quote work musically? You'd be surprised how many times I have heard a quote out of left field, particularly an obscure one, in a performance that is drastically altered harmonically by the inclusion of this unwarranted melody. You can have fun with quotes, but make sure they don't alter the harmonic content of the song. I have often used
Wolfgang Mozart's Little Sonata in C Major interspersed throughout the third repeat of the
A section of Joplin's
The Entertainer. I can get away with it for the novelty effect since they are in the same key, the harmonic content is, for the most part, retained, and I continually return to Joplin's melody.
Is it familiar? If you quote something that
you know but most people will not be familiar with, like
Bel´ Bartok's The Fly or some phrase from a
Benjamin Britten opera, you will lose the listener as thoughts such as "Huh? What? Was that a mistake? What is this fool doing?!" run through their mind. Lastly, don't consider quotes to be plagiarism or sacrilege, since they are included in the context of performance and not that of composition. Quotes are more an homage to the durability and adaptability of the original composer's tune. Still, this aspect is one of the better reasons to keep your quotes short. And you can "quote" me on that!