is there any missing data, like the distribution of X, or this is the exact question ? if so, try to open the expression you have got for the expected value, using simple algebra ((a-b)^2 = a^2 -2ab + b^2 ) and algebra of expected values, and see what you get, maybe you will get an expression dependent on a, and you can use calculus methods to get your answer.
if it doesn't work out, try to write the expected value as an integral and to differentiate it.
what also might help is to know that:
E[(X-a)^2] is minimized when a is E(X)
E[|X-a|] is minimized when a is the median
( just to give you some perspective of the kind of answer to look for...