There are a few ways to determine if a melody is in the public domain. One way is to check the copyright date. If the melody was published before 1923, then it is likely in the public domain. Another way to check is to see if the melody is listed in the U.S. Copyright Office's catalog of public domain works.
If you are not sure whether a melody is in the public domain, it is best to err on the side of caution and obtain permission from the copyright holder before you use it.