It seems that most of the pitot tubes are "L" shaped. However, there are some pitot tubes that shapes like a straight pipe. I am wondering that, for a straight pitot tube installed on the wing, what is the minimum distance the pitot tube need to extend out from the leading edge so it would receive free air and not the boundary layer air?
That’s going to vary from airframe to airframe based on windtunnel data. Ideally you’re searching for a place where the tube orifice has good access to free stream air that is undisturbed by airflow around the airframe, the wing etc. Also placement in a spot where interference is minimized by changes in angle of attack, side slip, etc. This minimizes discrepancies between calibrated and indicated airspeed.