I try to charge enough that I can do this work for free. But some customers don't like this arrangement so sometimes I have to make other arrangements. YMMV. The question really comes down to who gets to assume risk. There should be a financial premium on assuming risk to help even things out a bit.
Here's the basic issue:
The customer doesn't want to get stuck with an unknown bill for a project.
You don't want to get stuck with a whole bunch of work that brings your per hourly earnings down below what you can live on.
Resolving this conflict requires adding on a basic third piece:
- Whoever assumes the risk should get, on average, a modest financial reward for assuming that risk.
What I typically do is offer a rate that includes, free of charge, bugfixes afterwards for a year. That rate is double (!) my desired hourly rate. In most cases, I spend no time on after-market fixes. In a few cases I spend a lot of time. I try to plan so that I spend about 2/3 of my time as billable under this arrangement. This:
Protects my interests and ensures I am making money.
Protects my customers, ensuring they don't get stuck with large after-market bills.
For some customers though, they don't like this arrangement, and it breaks down for very large projects, so I also offer another rate in those cases (not advertised and sometimes as low as 50% my initial offer rate) with the explicit terms that the work comes with no warranty.and that I will bill for everything. On average I make a little less on these projects, but I also bear none of the testing and bugfix risk.
TL;DR: I try to throw in these free of charge by billing at a rate that allows me to make more doing this. For large projects, or certain customers, I may however shift the risk to the customer and offer a large discount. I believe that this approach best meets the interests of all involved.