See 
  
  
    
        
           | 
           if (!df.isPrefixOWLOntologyFormat()) {  | 
        
    
   
 
You cant inject a prefix into a OBO format serialisation pipeline (where OBO format is the last step), but you can inject it into some other format (like ofn), save it, and then convert to OBO in a separate pipeline.
I guess this could be an OWL API issue, falsely claiming OBO is not a isPrefixOWLOntologyFormat().