Change this SPARQL query
You have just to replace wdt:P921 with wdt:P921/wdt:P279* (see here for the new query).
wdt:P921/wdt:P279* is called property path. Such expressions are used for concatenating more properties in a single path which must comply with a certain structure. In this case, we are saying that the object of wdt:P921 can be the subject of wdt:P279 (* stands for "zero or more times") and the final object of such optional (chain of) wdt:P279 must be wd:Q11660.
Check out SPARQL 1.1 Query Language § 9 Property Paths for deepening this topic.

I have a query "change the number of publications on artificial intelligence over time." Can you help me change this query not only about artificial intelligence, but also about subclasses of artificial intelligence?
SELECT ?year (COUNT(DISTINCT ?item) AS ?count)
WHERE {
  ?item wdt:P31 wd:Q13442814 ;
        wdt:P921 wd:Q11660 ;
        wdt:P577 ?date .
  BIND(YEAR(?date) AS ?year)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
 GROUP BY ?year
 ORDER BY ?year

