Could be a coil pack, which is the modern (expensive) equivalent to a spark plug wire.
Or your car could be having "serious" engine problems like my 2000 Ford Taurus in Nov. 2006. The darned thing would randomly miss so badly that it would stall out. Then it would be "good" for a while before it did it again.
Problem was, it would never "work" for auto inspection people, so I couldn't get it to pass. We tuned up, changed coil packs, and in the end the mechanic said something like, "how much do you like this car"?
I said, "Well, it's a car with 105,000 on it, dented fenders scratched windshield". He said, "unless you want to put a thousand or two back into the engine, it's time to find a better car".
I hope it's not the case for you, maybe it will be something simple, like a fuel filter, spark plug, or coil pack.