The Flag Code states the flag should be presented to the "next of kin".
Just as an aside, the Flag Code does not actually say this -- it does not deal with funerals other than to specify how the flag is supposed to be placed on a casket. The handling of the flag in military funerals is covered in military regulations. For example, the US Army Field Manual on "Drill and Ceremony" (FM 3-21.5) says:
"For flag folding, upon conclusion of “Taps,” the representative and his assistant move closer to the casket. When the flag is secured and raised, the detail takes three steps away from the mourners and fold the flag. When the flag is properly folded, the detail assistant hands the flag to the detail leader and posts to a position next to the side or rear of the family. After the assistant departs, the detail leader presents the flag to the next of kin using the following wording: “As a representative of the United States Army, it is my high privilege to present to you this flag. Let it be a symbol of the grateful appreciation our nation feels for the distinguished service rendered to our country and our flag by your loved one.” After presenting the flag, the detail leader offers condolences."
The other services have similar regulations, although the exact phrasing of the presentation varies.
Peter Ansoff