That is determined by agreement between buyer and the real estate broker or it's agents.
Most often, a buyer authorizes their agent to negotiate a commission through cooperation with the listing company.
Sometimes the buyer will pay a portion of the commission directly to their own agent/broker at closing. When this happens, the amount
is usually added to a buyers closing costs and collected at closing.
On rare occasion, and usually for tax reasons, a buyer will pay the entire commission to their agent. Terms of payment, vary from transaction to
transaction.
How much, if any, that you pay out of pocket depends on what you agree to when you sign your agreement for representation. This is
requried to be discussed "up front" and you will NEVER be surprised by additional amounts due at closing.