Both these source localities are on the banks of the Rhine, respectively, at 12 km and 20 km upstream from Bonn.
In the above sentence, is respectively needed, and if so, is it properly used?
In the question as it stands, out of context, there is some merit to FumbleFingers' comment “it's not appropriate to use "respectively" to link the sequence of the two distances upstream to that of the two [unnamed] sources”. However, as you may observe in answers and comments at ELU question 34843, some sentences use respectively to indicate that things are separate. The need to so indicate does not depend on whether things are named. For example, consider the following two sentences about two treasures.
Treasures X and Y are on the banks of the Rhine, at 12 km and 20 km, respectively, upstream of Bonn.
Treasures X and Y are on the banks of the Rhine, at 12 km and 20 km upstream of Bonn.
The first form explicitly places one treasure 12 km upstream and the other 20 km upstream. The second form is ambiguous, if we suppose parts of a treasure may be at multiple locations. The same cases apply if “Treasures X and Y” is replaced by “The treasures”, without names.
The location of respectively in the sentence in the question is awkward and the comma after it does not help. Lots of readers would expect the list to precede respectively, and will be briefly taken aback by the awkward location of it in the example sentence. You can find more answers about locating respectively before a list in ELU question 197570.