The musical term enharmonic describes a note or notes which are the same, but whose spelling is different, or changed upon subsequent appearances. For example, a pitch written as an E♭ in one measure might be written as a D♯ in the next. On a piano, these note names represent the same pitch, so composers have a reason for changing the spelling.
Generally speaking, a sharp or flat, especially when it's not part of the piece's key signature, implies a sense of direction as to where it is leading. In this sense, an E♭ wants to resolve downwards to a D, but a D♯ wants to resolve upwards to an E. So when a composer changes the spelling of a note, they are indicating to the performer that the note's function has changed. Almost invariably this follows a drastic shift in harmony, making this practice one technique in which composers can change from one key to another, also known as enharmonic modulation.
It is also important to note that in a choir, string quartet, orchestra, or other group of singers or instruments who can freely adjust intonation, a note's enharmonic equivalent will likely be tuned slightly differently. 
- For an interactive online demonstration of this concept, see http://demonstrations.wolfram.com/ChordsInEqualTemperamentAndJustIntonation/