We did it at exactly the right time vs We did it at the exactly right time.

In the first example, exactly modifies the adverbial phrase "the right time." It is, thusly, an adverb modifying another adverb, which is correct. In the second example, "the right time is the object of a preposition and must be modified by the adjective "exact" rather than the adverb "exactly."