|   | 1 |  initial version  | 
Not satisfactory, but you can do:
sage: eq.subs({B: sqrt(17)}).subs({sqrt(17):B})
691254*B*x^15 + 397953*x^16 + 244005777*x^14
|   | 2 |  No.2 Revision  | 
Not satisfactory, but you can do:
sage: eq.subs({B: sqrt(17)}).subs({sqrt(17):B})
691254*B*x^15 + 397953*x^16 + 244005777*x^14
That said, since your expressions are polynomials (they do not involve things like log, sin,...), you can work in a well defined polynomial  ring:
sage: R.<B,x,y> = QQ[]
sage: R
Multivariate Polynomial Ring in B, x, y over Rational Field
sage: eq.mod(B^2-17)
691254*B*x^15 + 397953*x^16 + 244005777*x^14
 Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
 
                
                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.