Can an online course replace "ground school"?
Here in the states this depends on if you are training at a part 61 school or part 141 school 

Strictly speaking there is no ground school requirement for a part 61 school and you are even allowed to study the material on your own. However your instructor must endorse you for the written test so many schools prefer to know that you did at least some ground school usually from them. Online is more than acceptable in this case (especially if they provide you with the endorsement) however its best to talk to your instructor before doing so and make sure they are ok with it. 


  §61.103   Eligibility requirements: General.
  
  (1) Conducted the training or reviewed the person's home study on the
  aeronautical knowledge areas listed in §61.105(b) of this part that
  apply to the aircraft rating sought; and
  
  (2) Certified that the person is prepared for the required knowledge
  test.
  
  (e) Pass the required knowledge test on the aeronautical knowledge
  areas listed in §61.105(b) of this part.


For part 141 it depends what they got approved in their curriculum. You can find the full regulation here. 


  §141.55   Training course: Contents.


In the 141 case you most likely can not complete the training on line due to the fact it wont fall under their approval. 

Also of note from this FAA doc 


  Note: If you are enrolled in a part 141 school with test examining
  authority, the school will administer the knowledge test during the
  curriculum.




Its important to note that it does not matter if you are training at a part 61 or part 141 school you end up with the same PPL. 



You can find 100% of the information you need to pass the written test for free in the FAA's published handbooks particularly this one. 



On a bit of a personal note, I started at a 141 school that shut down about half way through and finished my PPL at a part 61 school (with the same instructor). At the 141 school there was a rigid curriculum and almost always a half hour to hour of ground instruction prior to our flight as dictated by their approved curriculum. At the 61 school I was allowed to work the material at home before hand and come in mainly for my flying but 15 min of discussion usually occurred prior to my flight anyway. I did at least 50% of the ground material on my own and passed the written without any issues but its important to understand what you are undertaking if you go the self study route.