A Real Estate agent can be paid a fee for services by either the buyer or the seller.
It is determined by your Buyer Broker representation form and Information About Brokerage Services.
This is a form that you should be presented with at the beginning if your relationship.
In many cases the seller pays the fees of both the listing and selling agents.
If you want to assure that your agent is working only for you it may be that you will want to work out an agreement where you agree to pay the agent yourself.
It is very important that everyone involved with the transaction knows who is paying the fees.
Communication is always key to a happy successful transaction.