A FOREIGN KEY declaration tells the DBMS that a non-NULL value for a subrow for its columns must also appear in the REFERENCES table as a value for a subrow for its columns. If that's what you want, declare it. If that's not what you want, don't.
You say that Task has FOREIGN KEY Task (projectID) REFEFERENCES Project (projectID)
. But then you contradictorily say that you want a projectID value in Task even if it isn't a projectID value in Project. Because if that's what you want then you do not want the foreign key. So don't declare it.
We do not need to declare foreign key, primary key, unique or other constraints in order to query. They just tell the DBMS that certain things will be true for valid database states. (So it can keep out invalid states and also optimize queries.)