Typically the cause is water staying in the water heater too long. This causes the water to turn stagnant. Single-handle type water faucets are typically being used in these situations and are not being fully turned to the cold position. This can occur when a water heater is too large for the amount of hot water typically used. It can also occur when the dip tube (cold water inlet) in the water heater deteriorates.
Flushing out the water heater will provide an immediate temporary solution. Long-term solutions for low usage are to decrease the size of the water heater, or to use more hot water. If the dip tube has deteriorated, it must be replaced.