Coming Out From Behind The Wall
Maybe. Here's the thing. If the Rogue has to come into the open to do this, he's no longer hiding (you can't hide in the open). No spot check is needed to see the Rogue if he just walks out into clear sight of the Ogre, he's no longer hidden. As he's no longer hidden, he'll need some other condition to allow for a Sneak Attack (flanking for example).
This is one of the reasons why Hide In Plain Sight is so good. If you had that, the Rogue could attempt to remain hidden even out in the open and this would work. Shadowdancers for example can stay hidden if they're near a shadow. That would include the shadow of the wall or the Ogre itself, making it a LOT easier to attack while hidden.
Rules Compendium Changes
The Rules Compendium (page 92) adds some extra things to Hide, if you're using it. Those address coming out from hiding a bit differently. In this case the answer would be Yes, if you can make the new Hide check as detailed below.
Move between Cover: If you’re already hiding thanks to cover or
concealment, and you have at least 5 ranks in Hide, you can make a
Hide check (with a penalty) to try to move across an area that doesn’t
offer cover or concealment without revealing yourself. For every 5
ranks in Hide you possess, you can move up to 5 feet between one
hiding place and another. For every 5 feet of open space you must
cross between hiding places, you take a –5 penalty on your Hide check.
Movement speed penalizes the check as normal.
Sneak up from Hiding: You can sneak up on someone after emerging from a hiding place. For every 5 feet of open space between you and the target, you take a –5
penalty on your Hide check. If your Hide check succeeds, your target
doesn’t notice you until you attack or perform some other
attention-grabbing action. Such a target is treated as being flat-footed with respect to you.
Yes. It's specifically mentioned in the Hide skill:
If you’ve already successfully hidden at least 10 feet from your target, you can make one ranged attack, then immediately hide
again. You take a -20 penalty on your Hide check to conceal yourself
after the shot.
Being aware of someone isn't enough to prevent Sneak Attack. If the spot checks fail against the new hide check, then the Rogue is hidden again and can continue to sneak attack.
Hiding and Sneak Attack
Yes, being hidden with Hide makes you effectively invisible, which normally allows Sneak Attack. Again from the Rules Compendium (p. 92):
If you’re successfully hidden with respect to another creature, that
creature is flat-footed with respect to you. That creature treats you
as if you were invisible (see page 76).