What is correct in a sentence: "Only then can you do" or "only then you can do" ?
After only then in this context, inversion is pretty much obligatory.
The phenomon that the normal order of sentence elements is changed is called inversion, subject-verb inversion. Inversion is found regulary if the first position of the sentence is occupied by an adverb with negative or restricting character. Such adverbs/adverb groups are: hardly, scarcely, never, no sooner, under no circumstances, in vain and similar expressions. In spoken language the regular order of sentence elements is perferred. "only then" is an adverb group with restricting character so in written style you will find inversion. But this does not mean the normal sentence order is impossible. And of course there are other types of inversion.
In your first example, you have given an example of V2 (verb-second) order. This was the default syntax of Anglo-Saxon. The verb was almost always the second element in the sentence. Let us take a closer look at your example:
'Only then can you do.'
I have italicized the adverbs. As you can see, they form a sort of adverbial unit. After them is the verb in the second position. Then we have the subject you and then another verb; in Anglo-Saxon, the subject often succeeded the verb. I will give another example below:
'Over tips the boat.'
'The boat tips over.'
As you can see, both of these sentences sound natural, while 'over the boat tips' does not. Although we are seeing more frequent use of simple SVO (subject-verb-object) order where V2 was historically preferred, V2 is still prevalent in many constructions. Your example is one of these.