I think it is very difficult for a non-native speaker (and sometimes a native speaker) to know when to use these phrases.
I have certainly used them numerous times with (good) friends, usually followed by a raise of the eyebrows and a smile, and no one has ever been offended. In such situations, they usually smile too. So here I would translate them as "Come on, you're smart: I know you know the answer to that!" I wouldn't call this use "sarcastic."
I have also used them in arguments, not followed by any sort of smile, when the other person is being unpleasant. (Never throw the first punch...) The other person was not generally amused. Here I would translate them as "What are you, stupid? The answer is obvious." I would call this use "sarcastic."
I have had the phrase used towards me as well, in both situations. In the first, I laughed along. In the second, I responded in a similarly sarcastic tone (if I could: sometimes, the other person was right).
Occasionally, I thought the situation was one of the above, but in fact it was the other one. Then things got messy.
So for a non-native I would confine the usage to the first situation until your fluency improves to the point that you feel you can handle the second situation.