1. All they had to do was go to one of these places.

2. All they had to do was to go to one of these places.

(Are both grammatically correct? Which one is grammatically correct?)

3. All you have to do is finish your homeowrk.

4. All you have to do is to finish your homeowrk.
(What about this one? Are both grammatically correct?)

Both 1 and 2 are grammatically correct. 2 is more complete, but both are OK and commonly used.

Same for 3 and 4.

Both sentences in numbers 1 and 2 are grammatically correct. In these cases, the use of "to" before the verb "go" is optional. Therefore, both versions are acceptable.

Similarly, both sentences in numbers 3 and 4 are grammatically correct. The inclusion of "to" before the verb "finish" is also optional in this context. So, you can choose to use either version. Both sentences convey the same meaning.