How to calculate the mass of an element in a sample of a compound?
As suggested in the comments, keep track of the units!  If your answer doesn’t make physical sense, you made a mistake.  

A thorough approach to this problem is to:


  
  calculate how much glucose you have.  
  calculate the fraction of oxygen in glucose.  
  multiply the (unitless) fraction found in (3) by the total glucose calculated in (1).
  


Using the values (and associated units) given in your problem:  


  
  $0.5 \pu{\frac{mol}{L}} \text{ glucose}\times \pu{1 L} \text{ glucose}\times \pu{180.16 \frac{g}{mol}}$ glucose = $\pu{90.08 g}$ glucose.  
  $\frac{\pu{96 g mol^-1} \ce{O}}{\pu{180.16 g mol^-1} \text{glucose}} = 0.533$
  mole fraction of $\ce{O}$ / glucose.  
  $0.533 \times \pu{90.08 g}$ glucose = $\pu{48 g} ~\ce{O}$
  


Of course there are many shortcuts you could take or even different approaches altogether, but I like to parse a problem like this down stepwise in a way that shows what you are doing and facilitates keeping track of units.  This makes troubleshooting much easier and systematic if you find you've made a mistake or want to walk through it a second time to verify what you've done (as you definitely should!).