The grammatically correct answer is "whom".
Ignore those WHO tell you it is OK to go ahead and violate the rules because everybody else does it. Doing it right will benefit you in many ways:
1) You will sound educated. The fact that so many people don't know the difference between "who" and "whom" means that few people will notice when you make a mistake. Because of that, and because you are person who is learning English, *PEOPLE WILL NOTICE* when you do it right. It will make a positive impression. You will sound smart.
2) Your meaning will become more clear because "who" and "whom" serve fundamentally different purposes.
Those two reasons are important, but not nearly so important as the third one:
3) Trying hard to always make the correct choice will force you to think about grammatical structure as you speak. It will force you to be aware of the role that each word plays in your sentences. Making an unrelenting effort will help you to think logically. You will become a better thinker, not merely a more eloquent speaker.
All that said, your sentence was not a very good one even if you choose the correct word. It is a bad example to learn from because it is so poorly worded. I honestly cannot tell you what it means. If was meant to be a question, it needs a question mark and it should start with "do":
"Do you know for whom to buy this?"
That is a good sentence, but also a rather strange question to ask. Without knowing what the author intended, I can only guess how to reword it.
No matter what it means, "whom" is needed because it is the direct object of the preposition "for". Direct objects are always in accusative case. Here's a harder example:
"That was a bad thing for ME to say".
Me is the correct word, not "I", because it is the object of the preposition "for".