Which of the following is grammatical?
- Can you please let me know by when you want it completed.
- Can you please let me know when you want it completed by.
I am preferring the latter, but will really appreciate your professional advice.
They're both correct.
Number 1 is perfectly fine, especially for written language. Number 2 is more natural, especially when spoken, or in an informal email. The only thing is that number 2 ends with a preposition, which might be frowned upon by certain people. There's a principle you hear sometimes where ending sentences with prepositions is forbidden. But see for example http://www.oxforddictionaries.com/words/ending-sentences-with-prepositions
In direct and indirect questions, words such as who or when usually move to the front of the clause or sentence that they occur in. Why do I say move? Well, although it is less common, with direct questions you can leave them in the same place that they would be in a standard affirmative sentence:
Compare this with the typical question forms:
Note that when we move the question word to the front of a direct question we have to reverse the subject and the auxiliary verb. (Sometimes the -wh word will already be at the front: who shot JR: here we won't get any inversion).
Often, the question word will be the complement of a preposition, for example with or by:
If we want to put questions like this in a normal question form we have a choice: we can either move the preposition and the question word (the complement of the preposition):
-or you can just move the question word:
These last examples exemplify what grammarians call 'stranded prepositions'. The reason for this is that the preposition which governs the question word has been left behind at the end of the sentence. There used to be a myth that it was ungrammatical to finish a sentence with a preposition. However, a survey of the greatest and most skilful writers in English will show this to be a lie. Modern grammarians and other linguists have spent years having fun ridiculing this idea.
In your examples, the interrogative phrase is part of an indirect question. The question word here must move to the front of the clause, but whether the preposition goes with it is entirely up to you!
I cannot comment on which is proper, but as a native English speaker the first sounds formal and would probably only be heard from the older generation.