The accidental will apply to following notes in the same measure / bar but not after that. If it is needed to cancel the effect before then another accidental (maybe a natural sign) will be required.
Oddly, although a sharp or flat in the key signature affects the same note in other octaves, an accidental does not.
An extra point thanks to Arthur. In the case of a tie across bar lines, it also lasts for the remainder of that tie (but not to the rest of the second bar).
And thanks to Guy G, note that odd exceptions may occur. Some older manuscripts may expect that the accidental applies to other octaves.