Using the preposition 'by'
Showing nearness, cause, or agent.
Examples: He left his briefcase by the door. He was frightened by the loud noise. The rates are regulated by the central bank.
Using the preposition 'for'
1. Showing how or why something is used, or for whom something is done.
Examples: This folder is for recent reports. He was honored for his achievements in molecular biology. I have a present for you.
2. Showing how long something happens:
He is going to Russia for five days.
3. Showing direction:
This is the train for New York. [Note the implied purpose: for = for going to]