The two above terms ''Billy'' Yank and ''Johnny'' Reb are closely associated with only one period of American History – that of The War Between The States (1861-1865). Seen as nicknames, they were also used somewhat derisively by both Northern and South Soldiers, as a way to identify each other.
Just ''who'' coined the nicknames is unknown. From the average Confederate Soldier's point of view, ''Billy'' was a common diminutive of ''William'' – an also a quite common name for Men who came from New England. The ''Yank'' attachment was shortened from ''Yankee'', also common to describe people from The New England States. Later, ''Yankee'' was seen as meaning ANY Soldier or person from The Northern part of The Country. Hence, ''Billy Yank'' became the unofficial call and identifier used by most Confederate Soldiers.
Not to be undone, Confederate Soldiers were too ''gifted'' a nickname by their Northern counterparts. For a typical Union Soldier, ''Johnny'' was a very common name given to Southern Men and quickly applied to any Southern Soldier – a ''Johnny''. The application of ''Rebel'' was a direct slander to their actual rebellion against Federal Law and Authority. Hence, ''Johnny Reb'' (shortened from ''Rebel'').
Many accounted from both sides (from letters and diaries), cite the use of both phrases. It no doubt served as a means to also dehumanize one's Enemy (by not knowing his actual name, and thus making killing him more difficult at times).
Other than The American Civil War, ''Billy Yank'' and ''Johnny Reb'' were not used in future American Wars. Of note, ''Yank'' would still be used (mostly by British Soldiers and populace) – as an identifier for any US Soldier, during both WWI and WWII.