I don't know if this is considered to be a natural reaction or not. Sometimes I mispronounce the N to NG if the next word starts with "th" or etc. Like "throw another shrimp on the barbie". When I run the words "shrimp", "on", "the" together, I sound like this:"shrimpong the barbie". My tongue would automatically place backward in convenience of pronouncing the "th" sound. Is it that my pronunciation is wrong? Or is it really a common phenomena? Is there a saying that words end with "N" sound should be changed "ng" sound in certain case?
As far as I know, pronouncing "on the" with [ŋ] (the "ng" sound of "song") isn't usual in native English accents. English speakers usually have some gestural overlap between a nasal and a following consonant (related question: Why do dictionaries transcribe the nasal in 'think' and 'language' with /ŋ/, yet 'input' and 'inbox' with /n/, not /m/?). This means that a nasal in this position tends to sound like it has the same place of articulation as the following consonant. Gestural overlap is especially likely to affect coronal consonants such as /n/ (in fact, non-nasal coronal consonants such as /t/ and /d/ also have gestural overlap with a following consonant in many contexts, so e.g. a phrase like "good boy" may be realized with [bb] or "outpost" may be realized with [ppʰ]).
The word "the" in a standard English accent starts with the consonant phoneme /ð/. This can be realized in a few ways, as a voiced dental fricative [ð] or sometimes as a voiced dental stop [d̪]. Sometimes, it can even be lenited to an approximant or elided entirely, or assimilate in nasality to a preceding /n/. However, I don't know of any accent where the definite article is commonly realized with a velar point of articulation. So it would not be expected to cause a preceding /n/ to be pronounced as [ŋ]. It would be expected to cause a preceding /n/ to be realized as a dental nasal, [n̪].
To summarize, I would expect "shrimp on the barbie" to be pronounced with something like [nə], [n̪ə], [n̪ðə], [n̪d̪ə]. I would not expect [ŋ] to show up.
I have read that there are some languages where coda nasal consonants tend to be realized as velar [ŋ] even before coronal consonants, but English is not one of them as far as I know. It occurs in some Romance languages, like Neapolitan Italian, according to the following document: "Separating the Root Node: On Coda Velarization in Romance", by Barbara E. Bullock (example: "[sjeŋtə] 'listen' 3.sg.", p. 48). Maybe the general linguistic tendency that causes this phenomenon in some Romance languages has affected your pronunciation of English.
For a native English speaker, it would be natural for "on" to sound like "ong" before /g/ or /k/, for example, in a phrase like "on good terms with..." or "Committee on Commercial and Industrial Policy".