This is a phrase that you use when someone compliments you, and you want to thank them for giving you the compliment.
The example above uses the word "sweet". Calling someone sweet is good, but it's usually said to someone younger or lower-status than you. So it can sound patronizing if you use it with someone your own age and social status."Sweet" is also not often used by men.
For someone who's higher-status or older, you might use the word "kind". A good neutral term to use with anyone is "nice":
Thank you, that's so nice of you.
There is a longer version of this phrase, which is "that's (nice / sweet / kind ) of you to say so. You can use this version when you want to seem humble. It means that you don't believe the praise that they've given you:
It's very kind of you to say so.