There are a couple of ways to achieve this. If a whole section of music in a particular part is to be played an octave higher when repeated, simply use text. Something like "8va 2nd time" at the beginning of the passage you want an octave higher, is perfectly clear. You could use a dotted line to show the exact group of notes to be played an octave higher if necessary. If you only want a few notes in a part to be played an octave higher on a repeat, you could add these notes above the notes to be played the first time, and make the note size smaller or bracket the noteheads. You could also then use text to be absolutely clear, for instance by adding something like "2nd time" above the first bracketed note. However, this use of small or bracketed notes, for a change on a repeat, is fairly common, so the text may not be necessary. Having said that, it is often useful to use a short amount of text to make your meaning clear.
If it is not clear when the player should return to playing at pitch, for instance if it is not simply after the repeated section, you use the term loco to show that the music is to played at the written pitch.
Also, to answer your additional question, the markings above would be understood to only apply to one instrument, and so one stave, in a score, if the instrument only uses a single stave. This is the case for most instruments in a score. Piano, harp and other keyboard instruments, on the other hand, are examples of instruments using two staves; in this case you need to use a dotted line to make it clear which stave has the octave adjusted. If only a text marking of "8va 2nd time" we're put above a section of piano music, it wouldn't be clear if this applies to both staves or just one.