It's only when a member gives you rep. This can be done by clicking on the star icon on the bottom left of someone's post. Once hovered over it, it will say, "Add to this user's reputation" which increases their rep, the amount depends on how much rep power you have.
You cannot gain rep with posts. Also, I don't think you are allowed to beg for rep as well, not entirely sure though.