If a coworker lives near your home and drives you to work every day, you may not be legally required to pay for gas, but offering to contribute is generally a thoughtful and respectful gesture. You are benefiting from their fuel, vehicle, time, and effort, particularly if they have to make even a small detour to pick you up. A regular arrangement should ideally feel mutual rather than like a one-sided favor.
The contribution does not have to be complicated. If your coworker is already traveling the same route, you could offer a reasonable amount each week or month toward fuel. If they regularly leave earlier or make a significant detour specifically for you, offering a little more would make sense. There is usually no need to calculate every mile or divide every expense precisely.
Gas is also only one part of the cost of driving. The person behind the wheel is responsible for maintenance, tires, repairs, insurance, and vehicle depreciation. That does not mean you need to pay half of everything, but it is another reason why contributing something toward the commute can be considerate.
The simplest approach is to be direct and appreciative: “I really appreciate you driving me to work every day. I’d like to contribute something for gas—what do you think would be fair?” If they genuinely do not want money, you could occasionally buy them coffee or lunch or give them a gas-station gift card. The important thing is to acknowledge the favor instead of assuming the rides should always be free.