For a wideband O2 sensor you definitely want it a proper distance from the engine - 2-3' is about right. Unlike narrow band sensors widebands work at a specific temperature and too close to the engine will initially give inaccurate readings and eventually bake the sensor. Don't locate the bung in such way that moisture will collect around the sensor as they are ruined in damp conditions - you generally want it on the lower side of the pipe. Ideally use a thick bung - you don't want the sensor sticking up in the center of the pipe, you want it near the pipe itself. I would recommend wiring the sensor to work only with the engine running rather than just with the key on - sitting around with the engine off but the sensor heater element on can shorten the life of the element and cause the potential for shock cooling when the motor is finally started. Related, wideband sensors are not really designed to be used in perpetuity - ideally, do your tuning then remove the sensor.