Expense ratios paid to mutual funds/ETFs are different from commissions paid to brokerages.
Money owed from expense ratios is taken out of the amount of money you have invested in a fund. For example, imagine a fund with an expense ratio of 0.50 and $100k invested. Assume the fund was completely flat on the year - didn’t go up or down at all. With a 0.50 expense ratio, your account balance would be $99.5k (-$500) after a year.
Common individual stocks do not have expense ratios (I’m not including more exotic exchange traded products like MLPs and BDCs). You don’t have to pay the company to own their stock. As the name implies, expense ratios are there to pay the expenses of the mutual fund management company (salaries, research, etc.).
You’re correct about commissions being collected when trades are executed. Different brokerages charge different amounts for different trades. Many discount brokerages (Ameritrade, Etrade, etc.) offer commissions in the $5-$10 range for individual stock trades. Commissions charged for mutual funds can vary based on a few factors: the fund family (Vanguard, Schwab, Fidelity, Pimco…), your broker (Ameritrade, Etrade, Merril Lynch, Fidelity…) and your brokerage’s relationship to the fund family.
As an example, consider Charles Schwab:
Schwab both operates as a mutual fund manager and a broker for individual accounts. If you hold your 401k, IRA, brokerage account, etc. at Schwab, they have an interest in you buying their funds. Thus, they allow you trade their funds for free. However, they still make money off of you because you have to pay the expense ratio. If you have an account at Schwab and wish to buy a Vanguard mutual fund, Schwab is going to charge a commission fee on the trade since they won’t be making any money on your funds parked with Vanguard.
That’s the dumbed down version. As you can probably imagine, there are various business relationships that affect who charges who what commission based on XYZ factors.