Which is grammatically correct?
I can only do so much in this time.
or
I can do only so much in this time.
In the given example there's not much difference. But there can be a great deal of difference in other constructions involving the same idea. Consider:
I only eat fish when I'm sick.
I eat fish only when I'm sick.
I eat only fish when I'm sick.
I submit that the first sentence is a bit ambiguous, and could be clarified in the direction of the second or third. Two and three mean entirely different things.
NOTE: In spoken English it is relatively easy to make the first sentence unambiguous by use of a vocal stress on the part you wish to indicate belongs with only.
I only eat fish when I'm sick. (I eat only fish when I'm sick.)
I only eat fish when I'm sick. (I eat fish only when I'm sick.)
I only eat fish when I'm sick. (I eat fish only when I'm sick.)
Certainly you can do the same thing in writing or typing via underlining or italicization, but sentence structure is perhaps a simpler way to draw the distinction, requiring no additional adjustments.
They are both grammatically correct, and both mean the same thing.
(However, "in this time" doesn't sound quite right in this context. "In the time available" might be better).
"Only I eat fish when I'm sick" means "Only I, and nobody else, eat fish when I'm sick". In this case, only is an adjective, qualifying the pronoun which directly follows it, I.
"I only eat fish when I'm sick" means "I only eat fish when I'm sick. That is the only thing I do with fish when I'm sick". In this case, only is an adverb, qualifying the verb which directly follows it, eat.
"I eat only fish when I'm sick" means "I eat only fish when I'm sick; I eat nothing else beside fish". In this case, only is an adjective, qualifying the noun which directly follows it, fish.
"I eat fish only when I'm sick" means "I eat fish only when I'm sick; when I am not sick, I do not eat fish." In this case, only is an adverb, qualifying the adverbial clause which directly follows it.
Robusto's answer provides an accurate, commonsense illustration of how the positioning of only in a sentence can significantly influence the sense of the sentence. The followup answer from systemovich offers what one might call the "strict constructionist" (or "machine-applied") interpretation of sentences that include the word only.
In a similar vein, Theodore Bernstein, The Careful Writer: A Modern Guide to English Usage (1973) lays out a "normal" practical rule for deciding where to situate only in a sentence:
ONLY
Normally the proper positioning of only requires no more than asking yourself, "What does it actually modify?" Thus a headline that says, "$35,000 Bond Thief Only Nets Paper," does not conform to the normal order; the only patently modifies "paper," not "nets," and so should adjoin it. An interesting exercise for developing only awareness was cited in the publication Word Study, distributed by G. $ C. Merriam Company, as follows: "Eight different meanings result from placing only in the eight possible positions in this sentence: 'I hit him in the eye yesterday.'" Try it.
However, to his credit, Bernstein goes on to note two important exceptions to the mechanistic assignment of only within a sentence:
The words "normal" and "normally" have been prominent in the foregoing paragraphs. They are intended to underline the fact that there are abnormal but proper placements for only. One abnormal placement is dictated by idiom, meaning that a normal placement would sound awkward and contrived. Example: "What is happening now can only be called a paperback-book explosion." The normal position for only here would be just ahead of "a paperback-book explosion," which is the phrase it modifies. But placed there, it sounds pedantic and unnatural.
Another "abnormal" placement, which is not really abnormal but only seems so, occurs when the only is a sentence adverb, that is, when it modifies an entire statement rather than a word or phrase. Example: "He only thought that he was being helpful." The only here is not intended to modify merely "thought," as would be the case if "thought" were heavily stressed. Nor is the meaning that his mental process was confined to a single idea, as would be implied if the only followed "thought." Rather the intention is to apply only to the entire sentence, and a sentence adverb of this kind usually precedes the verb.
Some combination of idiomatic usage and what Bernstein calls "sentence adverb" usage may well be at work in the expression "I can only do so much." An Ngram chart of "can only do so much" (blue line) versus "can do only so much" (red line) for the period 1850–2005 shows a rather remarkable increase in the frequency of the first expression since about 1970, a period during which the frequency of the second expression has increased only slightly:
Evidently, either there has been a startling increase in the frequency of instances where writers are trying to indicate that "they can only do so much" (as opposed to, say, promising so much) or the wording "can only do so much" has come into its own as a set phrase meaning "cannot do more than a certain unspecified maximum amount." The latter explanation is much more plausible than the former, in my view.
The latter is probably what you mean to say.
I can eat only so much in one sitting.
This means just what you think: In one sitting, you're only able to eat until you're full.
I can only eat so much in one sitting.
This implies that in this situation, you can only eat, as if you're compelled to do so. This is usually not what someone intends.
Robusto, et al, should be correct but "only" is a rather unusual word, in that context and idiomatic misuse normally overrule all else.
"in this time" and even the specific "do so much" blur the issue and generally, "I can only do…" should really be "I can do only…"
Consider instead "Only operate this machinery when sober".
Grammar suggests that should mean "Do nothing but operate this machinery…"
Context restores the sense of "Operate this machinery only when sober"