Very generally: Do for - it is a benefit. What can I do for you? How can I help you?
Do to - it causes harm, or it change it. What did you do to her? (What did you do that made her upset?). The printer was working a minute ago, and now it's not. What did you do to it? (What did you do that caused it to stop working?)