I can show you in some examples, but do not know the true grammatical explanation.
TO:
We are going to the park. I will pack a lunch to take with me. Don't forget to be careful. I am giving a gift to my sister.
FOR:
I bought a gift for my sister. I am eating a sandwich for lunch today. For my math homework, we have a worksheet.
BOTH:
To play the piano, you have to practice for 30 min each day.