In a pinch, you can guess the pronunciation by checking the particles:あと goes with で but のち goes with に。 Usually.
Each time you GO see Eazy-E rap, afterwards you buy some COCAINE from him.
|( xxxの ) あと ( で )||
after. Usually used like this: XXXの＊あと, or simply あとで！
|( YYYの ) のち ( に )||
after YYY (this means the same thing as あと, but sounds more like you're 50 years old. It's not formal but a bit old fashioned and / or literary)
|( ｚｚｚの ) うし*ろ ( で )||
physically behind ZZZ
|後||afterwards / behind||GO||行|
I GO behind you, with a garrotte STRING which ends your life.