You really need to talk to your coach. The scrumhalf's role in the scrum is absolutely critical and you need to be clear on this stuff.
Offside is a tricky subject in rugby, and its definition depends on the circumstances. But in general it means that you need to play offense from behind the ball carrier. In the ruck after a tackle you must position yourself behind the "hindmost" foot" of your side of the ruck. On offense it won't matter because you will be pulling the ball out of the ruck. On defense, just line up with the rest of your side behind the ruck. Lineouts are relatively simple -- you are to be within two metres of the lined-up forwards, ready to take a ball off the top, pull it out of a driving maul, or marking the opposing scrumhalf when they have the throw-in.
In the scrum, the scrumhalf is responsible for feeding the ball into the scrum and (usually) recovering it at the rear. You will always put the ball in on the side of your loosehead prop -- that puts your hooker closer to the ball and gives him an advantage with his strike. You hold the ball straight, with the long axis parallel to the ground. Immediately before the put-in touch your hookers hand (the one bound to the prop) with the ball to let him know it is coming. The put-in must be in the "tunnel" -- the gap between the two front rows -- and straight, although the official will generally allow you some leeway. A common trick is to tilt the ball so the right end is lower and spin it at the put-in -- this will naturally cause it to bounce towards your side of the scrum, and is perfectly legal. Practise this a few time and you will see what I mean.
After the put in you job is to follow the ball as it (hopefully) moves towards the rear of your scrum. Then -- depending on the situation you will field the ball yourself and (1) run with it; (2) pass off to your #10 or another back or (3) box kick the ball into enemy territory for your backs to chase. Another option is to slap your 8-man on the behind (telling him to unbind and field the ball himself) and then support his run.
The offside rule during a scrum varies on who has the put in -- if your side has the put-in you must keep at least one foot on your side of the ball. If the other team has the put-in you must keep both feet on your side of the ball. On defense your job is to stick to the opposing scrumhalf as closely as you can (while staying on-side) and do everything you can to disrupt his distribution of the ball.
There is a lot of information here to absorb -- and it takes experience. You might want to check out the Wikipedia article on playing rugby union ( http://en.wikipedia.org/wiki/Rugby_union_gameplay ). It has a pretty good explanation on play, with some useful links.