Flash Fire's boost ends when the battle ends, when the ability holder switches out, or when its ability is suppressed (Gastro Acid) or changed to something that isn't Flash Fire, such as if Houndoom Mega Evolves after sopping up a fire move. Other than that, it continues with no limit to its duration.