If during composition, an accidental note is used, is there a method/reason for using one name instead of the other?
For example if a song is in the key of A, but a Eflat/D# note is written is there a reason to use one instead of the other?
When to use which enharmonic equivalent is always based on the context you are in the melody and harmony. In your example in the key of A there are situations where you would use D# over Eb and there are times where you would use Eb over D#.
A simple example where you would use D# over Eb would be if you were using the progression A B E where B is V/V (the dominant chord of the dominant). The B chord contains the notes B, D#, and F# so you would obviously use the D# in this case.
A simple example where you would use Eb over D# would be if your melody was chromatically going down from E to D you would use an Eb to signify you are chromatically descending.
For more information, check out this question:
It's all about context. Chords should be spelled correctly, and if there's a choice between enharmonic chords, then we look at the chord's context. For a melody note that's outside the chord, it might be that it's implying a chord or extension of a chord, in which case that spelling should be honored.
If none of that is the case and it's just a non-chord tone out of the blue, then write whatever is less confusing. It's less visual clutter to go E -> E♭ -> D than E -> D♯ -> D♮, for example. However, it's similarly better to go E -> D♯ -> E than E -> E♭ -> E♮.
An accidental will change a normal note. By normal, I mean a note normally found in the current key - a diatonic note. It will depend on what has happened to that note. A couple of examples. In the key of C major, the harmony goes from C to F major. A new note comes along to help. It's a G#, making the chord a C augmented to move the harmony to F. Now, the F harmony changes subtly to get back to the C major. An A note changes to produce an F minor chord. It drops by a semitone to the same note ( in 12 et.) but this time, it's an A note that gets called Ab. In the 1st example, C+, the G has been raised to G#, whereas in the 2nd., the A has been dropped to Ab, as F minor has Ab rather than G# in it.
An exception to this may be a changed note (every accidental is a changed note, even a natural) and if there's no specific technical reason, then stick with #s in a # key, and b in a b key - but generally, the chord structure will dictate what the changed note needs to be called.