The first thing to note is that the two sets of words that you mentioned end with different sounds. The ones ending in th all have the [θ] sound, which is formed by putting the tip of the tongue between the front teeth and blowing. The ones ending in ht all have the [t] sound (or some allophonic variant thereof). If you're not a native speaker of English, you might have difficulty producing the [θ] sound or distinguishing it from [t], but for native speakers of English the distinction is perfectly clear, and so this problem never arises.
The secondary issue is that of spelling, as you find th and ht confusing. This is a matter of mis-parsing some common English digraphs. When attempting to read those words, you shouldn't take h and t together, but rather g and h together, as the digraph gh is pretty common in English, and is usually silent when it's not at the beginning of a word. (In a few words it's pronounced as [f].) In other words, whenever you see gh in words like this, you should completely ignore the gh, and read the words in your example as heit, tonit(e), fit(e), caut, etc. The fact that the h is next to the t is irrelevant, since the h is really part of the silent digraph gh.
A final, confusing issue is that a few words ending in -t are sometimes (mis)pronounced as if they ended in -th. For example, the word height in proper speech is approximately [hait], but it's often pronounced something like [haitθ]. This is due to influence by other words denoting qualities of measurement (length, width, depth) which all end in [θ].