to is preferable, in the sense of
which goes with, which belongs with (as a pair, usually).
the key to the door
the door to the garage
the entrance to the building
the combination to the safe
the attachments to this vacuum cleaner
the answer to the question
my response to her letter
Note that these expressions with
to are often in the context
of finding a smaller thing that goes with a bigger thing. The smaller
thing takes on the role of something missing (in a vague and broad
sense) that must be supplied to complete the pair.
But be careful - these can be highly idiosyncratic, and
for is often used the same way, and substituting one for the other will sound peculiar to a native speaker.
the remote for this TV
the cover for the pot
a belt for these pants
Also, many of these are alternately expressed as compound nouns.
the garage door, the door key, the pot cover
All in all, this topic can become quite a muddle.
There's no end
to the treats!
CJ